Academy
Magento 2 SEO Guide in short

Magento is an incredibly powerful platform, but in order to make the most of it you need to configure it properly. This guide shows you how to do exactly that, zooming in on:

  • Creating a SEO-friendly URL structure
  • Configuring page titles and meta descriptions correctly
  • Using headings correctly.
  • Taking search engines by the hand when they’re crawling and indexing your store.
  • Speed optimizing.

Magento, founded in the United States in 2008, has become a leading eCommerce platform worldwide. That position was strengthened further with their acquisition by Adobe in 2018.

It’s estimated that around 270,000 stores run on Magento world-wide. And according to Magento, they enabled their merchants to earn $155 billion in revenue in 2018. It’s safe to say that Magento is a household brand in eCommerce land.

While Magento 2 is a very powerful platform, if you’re running on its default settings, you’re not going to get great SEO performance out of it. That’s why you need to put yourself in the position to win, and by applying all the best practices for Magento 2, you do just that.

In this article, we’ll explain step-by-step what you need to do in order to get your Magento store into top shape, all set for maximum SEO performance.

What does it take to make your Magento store rank well?

In order to rank your Magento store well in the organic search listings, you need to make sure search engines can easily and efficiently find all your content and make sense of it, and that they have reasons to rank your content higher than others.

We can break all this down into the so-called “Three pillars of SEO”:

  1. Technology: the technical foundation of a website, which helps search engines find and understand your site as quickly and efficiently as possible. This is about setting yourself up for success.
  2. Relevance: what search queries your content is relevant for. This is done by creating content that’s useful and satisfying for your visitors. Good technology is essential in order to communicate relevancy clearly.
  3. Authority and Trust: links to your website; these determine your authority and trustworthiness.

This article describes the first pillar, Technology, in detail, as this is platform-specific, while Relevance and Authority and Trust work the same for every platform.

Useful resources

A Magento SEO checklist for a strong technical foundation

A strong technical foundation enables search engines to find and understand all your content easily and efficiently.

Think of a site’s technical foundation like a structure’s foundation. Having a solid foundation benefits the entire structure. Alternatively, having a shaky foundation causes the whole structure to fall down.

Here’s the breakdown of things you have to do or address to get the technical foundation right in Magento 2:

Defining a SEO-friendly URL structure in Magento 2

A good URL structure is one that works well for both visitors and search engines.

In a nutshell, your URLs need to be:

  • Descriptive and easy to read
  • Brief
  • Consistent
  • Lowercase

Website redirects and rewrite settings

You can manage a store’s redirects and rewrite settings by logging on to your Magento backend and navigating to:

  1. Stores > Configuration (under Settings) > General > Web.
  2. At the top of the page, select the right Store View you want to adjust the settings for. In our example this is Default Store View. Note: changing the settings on a higher level impacts other store views, so be careful with that. Read more on this here.
  3. Under Url Options you’ll find the field Add Store Code to Urls. Keep its value set to it’s default: No to make sure URLs are descriptive and easy to read.
  4. The field Auto-redirect to Base URL enables you to automatically redirect visitors and search engines when they request your store without the subdomain (e.g. when https://www.example.com is requested, clients are forwarded to https://example.com), or vice versa. While this is a great feature, by default it’s configured to use a temporary 302 redirect instead of a 301 redirect. Change this value to Yes (301 Moved Permanently) to make sure link authority from incorrectly placed links is passed on as much as possible to the right URL.
  5. Under Search Engine Optimization you’ll find the field Use Web Server Rewrites which is by default set to Yes. Keep it this way, as this determines that your store gets to use readable URLs.
Screenshot of Magento’s domain URL settings
Magento 2 domain URL settings.

Remove the .html extension from product URLs and product-category URLs

By default, Magento adds the .html extension to all URLs. It’s recommended to remove the .html extension to prevent potential issues further down the road, when switching to a different eCommerce platform.

The secret to defining a great URL structure is to think ahead. When you’re migrating to a different platform, you want to minimize the differences between both platforms.

To remove the .html extension from the URLs, log on to your Magento backend and navigate to:

  1. Stores > Configuration (under Settings) > Catalog > Catalog > Search Engine Optimization.
  2. At the top of the page, select the right Store View you want to adjust the settings for. In our example this is Default Store View.
  3. In the screen that this loads, you’ll find the fields Product URL Suffix and Category URL Suffix. Both fields have the value .html. Removing that value from both fields will lead to URLs such as https://example.com/category for category pages, and https://example.com/product for product pages. If you prefer to have a trailing slash at the end of all URLs, you can fill in / in both fields, leading to URLs like https://example.com/category/ and https://example.com/product/.
Screenshot of Magento’s URL suffix settings
Magento 2 URL suffix settings.

Keep URLs short by not including categories in URLs

In that same screen, you can choose whether or not to include the product-category key in a product’s URL, for example: https://example.com/category/product/.

By default, Use Categories Path for Product URLs is set to No. Keep it that way to ensure that URLs stay short. This is especially important if you have categories with subcategories; URLs will become very long quickly. If you have products with highly similar names, it’s recommended to include a unique identifier such as the SKU in a product’s URL. Out of the box, you can’t configure this in the Magento 2 backend, but you can use an extension for this.

Screenshot of Magento’s settings on using category keys in product URLs
Magento 2 settings for using category keys in product URLs.

Automatically redirect URLs if the key changes

In cases where URL keys change after pages have been published, you want to redirect visitors and search engines to the right URL when they request the old URL.

By default, this is turned on: Create Permanent Redirect for URLs if URL Key Changed is set to Yes. Keep it like this, it’ll save you a lot of headaches down the road.

Screenshot of Magento’s settings on redirection when URL keys change.
Magento’s settings on automatically redirecting URLs when their key changes.
Useful resources

Defining meta information in Magento 2

Your page title and meta description have a big impact on both your rankings and, when your page is shown in the SERP, your click-through-rate (CTR) as well. At the same time, you can’t manually define a title and meta description for each page, so you need to be smart about that. You need to use smart defaults, which can then be overwritten if need be.

Screenshot of a search engine result snippet from Google, with the title, URL and description highlighted.
A search engine result snippet from Google, with the title, URL and description highlighted.

What makes for a good title?

A good title is easy to read, contains important keywords, has a call to action, is unique, and has a length between 285 and 575 pixels (30 and 60 characters respectively).

What makes for a good meta description?

What goes for the title goes for the meta description, except that the preferred length is different. Keep the meta description between 430 and 920 pixels long (70 and 155 characters respectively).

Define the homepage meta information

To define the homepage meta information, log on to your Magento backend and navigate to:

  1. Content > Configuration (under Design)
  2. There, look for Default Store View and click the Edit link after it to adjust the Default Store View homepage’s meta information.
Screenshot of the Design Configuration screen in Magento 2
Navigating to the Default Store View homepage’s meta information in Magento 2.

Scroll down to HTML Head under Other Settings and expand the setting options:

Screenshot of the HTML Head homepage settings in Magento 2
Editing the Default Store View homepage’s meta information in Magento 2.

You can ignore the Default Page Title and Default Meta Description fields, as they aren’t used within Magento by default. Ignore the Default Meta Keywords field as well, as meta keywords haven’t been used by search engines for over a decade. They play no role in SEO.

The two remaining fields, Page Title Prefix and Page Title Suffix do matter:

  • Page Title Prefix: you want to keep this field empty, as whatever you add there is added at the start (the most important part) of the title. Having a generic prefix goes against everything we know about the title tag, so keep it empty.
  • Page Title Suffix: fill in - $shopName, for example: - ContentKing. This will be added at the end of every page title, which helps you from a branding point of view.

Define meta information templates for products and categories

Defining meta information templates for products and categories, which take up the lion’s share of a store’s pages, is what will save you the most time here.

Regrettably, this is a feature Magento itself lacks. It wasn’t available in Magento 1, and it isn’t available in Magento 2 either. Therefore, we recommend using an extension such as “Meta Tags Templates by Amasty” or “SEO Meta Templates by MageWorx”.

Here are some sample page title templates you can use:

  • Category pages: $categoryName | $shopName – so for example: “T-shirts for men | Joe’s T-shirts”.
  • Subcategory pages: $subcategoryName | $categoryName | $shopName – so for example: “Breaking Bad T-shirts | T-shirts for men | Joe’s T-shirts”.
  • Product detail pages: Buy $productName | $subcategoryName | $shopName – so for example: “Buy Mr. White T-shirt | Breaking Bad t-shirts | Joe’s T-shirts”. Here we’re deliberately leaving out $categoryName, as that would often make the title too long.

Here are sample meta description templates you can use:

  • Category pages: Looking for $categoryName? Check out our massive selection of $amountOfProducts T-shirts at $shopName!, so for example: “Looking for T-shirts? Check out our massive selection of 10,431 T-shirts at Joe’s T-shirts”.
  • Subcategory pages: use the same template as mentioned above for category pages.
  • Product detail pages: Buy a $productName starting from $productPrize. Shipping time: $shippingTime. Only at $shopName!, so for example: “Buy a Mr. White T-shirt for as little as $19.99. Shipping time: 24 hours. Only at Joe’s T-shirts!”.

Define meta information templates for other pages

For other pages, such as landing pages and About Us, you can use the following templates:

  • Page title: $pageName - $companyName, for example: “About Us - Joe’s T-shirts”
  • Meta description: Check out our $pageName page!, for example: “Check out our About Us page!”

Note that the suggested templates won’t work for every business, and they may not fit your style. Let them simply be an inspiration to you.

Useful resources

Using headings correctly

Whether headings are used correctly in your Magento store depends on two things:

  1. How headings are structured within your theme.
  2. How you use headings in your content – which is entirely up to you.

Here’s a quick refresher:

A good heading structure helps visitors quickly scan a page, and helps search engines easily understand its structure and topic.

Stick to these heading best practices:

  • Don’t wrap logos or images within H1 heading tags, as the H1 heading conveys the main topic of the page. Therefore, the H1 heading should include meaningful text.
  • Use only one H1 heading per page.
  • For readability, stick to a maximum heading length of 60 characters.
  • Build up your heading structure with a logical hierarchy, as illustrated below.
Illustration of the right heading structure
A document’s heading structure explained.
  • Be smart about your product-category, product, and page names, because these names will be used as the H1 headings by default.
  • Don’t use H1 headings in the body content, because that will lead to having multiple H1 headings (see above).
Useful resources

Crawling & Indexing

This section describes how you need to configure Magento to make it easy for search engines to crawl your store, and to understand what they need to index and what not.

Turn on the use of canonical URLs for products and categories

Canonical URLs give search engines a strong hint as to what page they need to index. So in a case where you have one product with multiple variants, and you want to signal to search engines that they are to only index the product page, and not the variant pages, then you can do so with the canonical URL.

By default, the use of canonical URLs is turned off in Magento. With this setting turned off, a product is available through both its own URL and a URL that includes the category: https://example.com/product/ and https://example.com/category/product/. This leads to situations where these pages are competing with each other for a search engine’s attention.

To turn on the use of canonical URLs, log on to your Magento backend and navigate to:

  1. Stores > Configuration (Under Settings) > Catalog > Catalog > Search Engine Optimization.
  2. At the top of the page, select the right Store View you want to adjust the settings for. In our example, this is Default Store View.
  3. In the screen that this loads, you’ll find fields named Use Canonical Link Meta Tag For Categories and Use Canonical Link Meta Tag For Products. Change their values to Yes. This will result in both product and product-category pages having canonical URLs, which significantly helps to prevent duplicate content.
Screenshot of Magento’s canonical URL settings
Magento 2 Canonical URL settings.
Useful resources

Use robots directives to prevent duplicate content

Robots directives communicate your preferences regarding crawling and indexing to search engines. Especially for larger sites – which eCommerce stores often are – robots directives are essential to SEO success.

Apply the noindex robots directive to internal search result pages

By default, internal search result pages in Magento 2 are robot-indexable. That’s bad from an SEO point of view, as this can lead to an enormous number of low-quality pages being crawled and indexed when there are links pointing to these pages (be these internal, or external).

We recommend adding the noindex, follow robots directive to all internal search result pages.

Apply the noindex robots directive to URLs with query parameters

eCommerce platforms are notorious for generating tremendous numbers of URLs because of query parameters. In Magento 2, URLs with query parameters are indexable by default. And that’s not a good thing.

For example, if you’re on a product-category page and you’re filtering on prices between $10 and $20, you’d be sent to to a URL such as https://example.com/category/?price=10-20. You don’t want that URL to be indexed, because it’s just showing a subset of the category products.

Sorted pages are another example: say you want to see the products in a category from cheapest to most expensive. You’d be sent to a URL such as https://example.com/category/?price=10-20&product_list_order=price&product_list_dir=asc. This page just shows the same products in a different order. This adds no value from an SEO point of view, so you don’t want these pages to be indexed either. The same goes for choosing to see more or fewer products on a page. That will add a query parameter to the URL too, leading to a URL such as: https://example.com/cateogry/?product_list_limit=30.

There are no native settings in Magento to manage the robots directives for pages such as these, so you either need to have this custom-developed and/or add a Layered Navigation Extension.

Besides adding a noindex robots directive, we recommend preventing search engine crawlers from accessing URLs with these query parameters in the first place as described in the robots.txt section.

Useful resources

An XML sitemap

XML sitemaps are an efficient way to communicate to search engines what pages they need to crawl and index.

The best practices around XML sitemaps are as follows:

  • Keep the XML Sitemap up to date with your website’s content.
  • Only include indexable pages.
  • Don’t list more than 50,000 URLs in a single XML Sitemap.
  • Make sure the sitemap’s (uncompressed) file size doesn’t exceed 50MB.
  • Reference the XML sitemap in the robots.txt file.

Magento 2 comes with XML sitemap functionality. To configure the XML sitemap, log on to your Magento backend and navigate to:

  1. Stores > Configuration (under Settings) > Catalog > XML Sitemap.
  2. At the top of the page, select the Store View you want to adjust the settings for. In our example this is Default Store View.
Including categories, products, and CMS pages in XML sitemap
Screenshot of the XML sitemap settings for categories, products and CMS pages in Magento 2
Editing the XML Sitemap settings for categories, products and CMS pages in Magento 2.

By default, the options for categories, products and CMS pages are configured correctly. Google doesn’t use the Frequency and Priority hints, so there’s no need to change anything there. By default, images are included in the XML Sitemap as well.

XML sitemap generation Settings

At the top of the page, select Default Config for Store View to manage the generation settings for the XML sitemap. The page will reload, and when you scroll down a little, you’ll see that you can define if, when, and how often the XML sitemap needs to be regenerated under Generation Settings.

Screenshot of the XML sitemap generation settings in Magento 2
Editing the XML Sitemap generation settings in Magento 2.

By default, the Enabled field is set to No. Change this to Yes, because you want your XML sitemap to be regenerated automatically.

Setting Start Time to 02:00:00 will ensure the XML sitemap is regenerated at 2 AM. This is just an example; change this value to the quietest time of day for your store, as regenerating the XML sitemap can temporarily make your Magento store slower.

Keep the value of the Frequency field set to Daily to make sure the XML sitemap is regenerated every day. This too is just an example: if the content on your store only changes once a week, it makes more sense to regenerate the XML sitemap once a week.

XML sitemap: limits and robots.txt

Things get interesting down below; under Sitemap File Limits, you’ll find the fields Maximum No of URLs Per File and Maximum File Size.

Screenshot of the XML sitemap file limit and robots.txt settings in Magento 2
Editing the XML Sitemap file limit and robots.txt settings in Magento 2.
XML sitemap: Maximum No of URLs Per File

For most Magento stores, the default Maximum No of URLs Per File limit is correct as it aligns with SEO best practices.

Pro tip

In case you’re running into indexing issues, it can be useful to temporarily split up your XML sitemap into more files so you can better pinpoint the indexing issues. For example, if you have 200,000 products split into four XML sitemaps and you’re encountering indexing issues, checking the Sitemap’s coverage report in Google Search Console doesn’t tell you that much. Dividing those 200,000 products up in say 20 XML sitemaps gives you better insights.

Alternatively, you could create separate XML sitemaps per product category to help pinpoint indexing issues within product categories.

XML sitemap: Maximum File Size

You can raise the maximum file size to 52428800, as this equals 50 MB.

XML sitemap: Enable Submission to Robots.txt

Under Search Engine Submission Settings you’ll find the field Enable Submission to Robots.txt, which has a default value of No. Switch this to Yes, as you want your robots.txt file to reference your XML sitemap.

Once this is all set up, it’s time to create the XML sitemap and configure its (re)generation settings. To do this, go to Marketing > Site Map (under SEO & Search) and click the orange Add Sitemap button.

Screenshot of the XML Sitemap overview Magento 2
Adding the XML Sitemap to the Magento store.

In the screen that follows, you define the XML sitemap’s name and location:

  1. Fill in the XML Sitemap’s name in the field Filename, example: sitemap.xml.
  2. Then fill in the XML sitemap’s path in the Path field – for example /pub/ in our case because of the nature of the Magento installation in our test setup.
  3. Next, click the Save & Generate button, and you’re all done!
Screenshot of the XML Sitemap filename and location settings in Magento 2
Configuring the filename and location of the XML Sitemap in Magento 2.
Useful resources

Robots.txt

The robots.txt file tells crawlers the rules of engagement when it comes to accessing URLs on your site. For eCommerce stores – and so this goes for Magento stores too – it’s essential to leverage the robots.txt file to send search engine crawlers in the right direction, and keep them from touching the wrong URLs in an effort to

While search engines claim to be good at recognizing crawler traps, they first need to go down one in order to find out only later that it is in fact a crawler trap.

Your Magento 2 store has a variety of URL patterns that you don’t want search engines to touch.

Here are the pages we recommend barring off from search engines:

  • Internal search result pages: /catalogsearch/ and /search/. While we recommend adding the robots noindex directive to these pages as a second line of defense, the first line of defense is the robots.txt file.
  • Login pages /customer/account/login/ – login pages.
  • URLs containing SID and PHPSESSID parameters.
  • Filtering criteria such as price, color, material and size.

This boils down to the following robots.txt:

User-agent: *
Disallow: /catalogsearch/
Disallow: /search/
Disallow: /customer/account/login/
Disallow: /*?SID=
Disallow: /*?PHPSESSID=
Disallow: /*?price=
Disallow: /*&price=
Disallow: /*?color=
Disallow: /*&color=
Disallow: /*?material=
Disallow: /*&material=
Disallow: /*?size=
Disallow: /*&size=

We recommend including both ways a criterion is included in URLs. For example, with price that’s both /*?price= and /*&price=.

Editing your robots.txt file in Magento 2

In order to edit your robots.txt file in Magento 2, navigate to:

  1. Content > Configuration (Under Design).
  2. There, edit the settings for Main Website instead of the Default Store View, because the latter won’t allow you to change the robots.txt file.
Screenshot of the Design Configuration screen in Magento 2
Navigating to the robots.txt settings in Magento 2.

On the screen that follows, scroll down to Search Engine Robots. There you can define your robots.txt content:

Screenshot of the robots.txt instructions field in Magento 2
Adjusting the robots.txt instructions in Magento 2.
Important

Note that you shouldn’t change the value of Default Robots, as that’s the site-wide robots directive value.

Useful resources

Faceted navigation

When we’re discussing crawling, indexing, and filters, we also need to touch on faceted navigation.

Faceted navigation refers to how visitors can search through your products. Product filters, for instance, are part of faceted navigation. While we recommended earlier that you add noindex robots directives to your filtered product pages, and also exclude them through robots.txt, what if people are searching for a certain subset of your products, say all black Breaking Bad t-shirts? In that case, you need to make that subset of your products available for search engines by creating a subcategory for it. Do this for all product subsets where it makes sense to do so.

This way you can cater to a larger audience, just by being smart about your product categories.

Use pagination attributes

By default, Magento isn’t using the prev/next pagination attributes link on paginated pages to explain the relationship among these pages. While Google has said they no longer need this attribute to make sense of a series of paginated pages, there are still other search engines out there. There’s nothing against using it, and we recommend adding it if it only requires a small investment in time.

For example, if you’re already using a SEO plugin such as SEO toolkit that contains this functionality, and it’s just a matter of switching it on: go for it!

Useful resources

Site speed

Magento requires quite some server resources to run smoothly, so having a solid, Magento-optimized hosting platform is essential to the success of your Magento store.

But you won’t get far with “muscle” alone; you need to configure both your hosting and your Magento platform correctly in order for it to take.

Requirements for your hosting platform

For best performance, your hosting platform needs to be:

  • Optimized for Magento
  • Ready to support Redis and Varnish
  • Running on Nginx
  • CDN compatible

Enabling caching features

To enable the built-in caching features in Magento:

  1. Navigate to System > Cache Management
  2. Mark all checkboxes, select Enable from the drop-down box, and hit Submit:
Screenshot of the Cache Management screen in Magento 2
Enable caching in Magento 2.

Enabling Full Page Cache in Magento 2

To enable full page caching:

  1. Navigate to Stores > Configuration (under Settings) > Advanced > System.
  2. Under “Full Page Cache”, you’ll find the Caching Application field. By default, it’s set to Built-in Cache. Change that to Varnish Cache (Recommended).
  3. Next, an additional settings screen named Varnish Configuration appears. There, you fill in whatever your hosting provider has provided you.
Screenshot of Full Page Caching settings in Magento 2
Enable Full Page Caching in Magento 2.

Configure JavaScript settings in Magento 2

Configure your store’s JavaScript settings by going to Stores > Configuration (under Settings) > Advanced > Developer.

There, expand JavaScript Settings and change the value of Merge JavaScript Files, Enable JavaScript Bundling, Minify JavaScript Files to Yes:

Screenshot of JavaScript settings in Magento 2
Configure JavaScript settings in Magento 2.

Configuring CSS settings in Magento 2

The configuration settings for your CSS files are located under the JavaScript settings in the same screen.

Expand CSS Settings and change the values of Merge CSS Files and Minify CSS Files, and – if your theme supports this – set Use CSS critical path to Yes:

Screenshot of CSS settings in Magento 2
Configure CSS settings in Magento 2.

Configuring Image settings in Magento 2

Configure your image settings by going to Stores > Configuration (under Settings) > Advanced > System.

There, expand Images Upload Configuration at the bottom and change the values for Maximum Width and Maximum Height according to your preferences.

Example: the image dimensions in your template have a maximum width of 600 px and a maximum height of 300 px. In that case, you can set those sizes for the maximum width and height. If you also have support for retina screens, you can double the sizes, leading to a maximum width of 1200 px and a maximum height of 600 px.

Screenshot of Image Upload Configuration in Magento 2
Adjust Image Upload Configuration settings in Magento 2.

By doing this, you avoid serving unnecessarily large images to your visitors.

Applying other best practices

Other best practices to speed up your Magento store that you can apply:

  • Using a Content Delivery Network (CDN).
  • Limiting the number of JavaScript libraries that are loaded.
  • Optimizing your images using image compression tools.

A note on Index Management

Refreshing indexes takes its toll on the Magento platform, so be careful not to refresh indexes after saving every change.

Personally, we’re fans of the Hypernode platform thanks to their performance, configuration flexibility, and support.

HTTPS

Serving your visitors over a secure connection is a precondition for success – and it’s fully supported by Magento. Especially for eCommerce stores, using HTTPS is essential, because it all comes down to earning – and keeping – your visitors’ trust.

Enabling HTTPS in Magento 2

Configure your image settings by going to Stores > Configuration (under Settings) > General > Web.

There, expand Base URLs (Secure) and change the values of Secure Base URL and Secure Base Link URL so that they start with https.

Furthermore, change the value of the Use Secure URLs on Storefront, Use Secure URLs in Admin, Enable HTTP Strict Transport Security (HSTS) and Upgrade Insecure Requests fields to Yes.

Screenshot of HTTPS configuration in Magento 2
Configure HTTPS settings in Magento 2.
ContentKing Academy Content Team
Steven van Vessum
Steven van Vessum

Steven is ContentKing’s VP of Community. This means he’s involved in everything community and content marketing related. Right where he wants to be. He gets a huge kick out of letting websites rank and loves to talk SEO, content marketing and growth.

Vojtěch Zach
Vojtěch Zach

Vojtěch is ContentKing’s Customer Support & Localization Manager. He is the one who will answer your questions when you reach out to us. He is a studied translator, so apart from making our users happy, he also loves to take on our localization challenges.

Lorena Torsani
Lorena Torsani

Lorena is ContentKing’s Marketing Specialist. She’s a creative thinker, who is highly enthusiastic about engaging with customers, running exciting campaigns and bringing forth some fresh ideas.

Start your free 14-day trial

Get up and running in 20 seconds

Please enter a valid domain name (www.example.com).
  • No credit card required
  • No installation needed
  • No strings attached