Adjusting our Magento configuration for SEO

A really quick and easy adjustment we can make to our entire website URL structure is to remove the default index.php string that is appended to the base URL—for example, http://www.mydomain.com/index.php/my-product.html—and also auto-redirect to our base URL if the non-www version of our domain is entered.

In order to achieve these small fixes, we should perform the following steps:

  1. Navigate to System | Configuration | Web | Search Engines Optimization and set Use Web Server Rewrites to Yes to remove index.php.
  2. Within this same section but under URL Options, set Auto-redirect to Base URL to Yes (301 Moved Permanently).

As long as our server has been configured correctly and our default .htaccess file is in place, Magento will automatically remove the index.php string from our URLs and continue to serve our pages as normal. By performing the preceding steps we will also be setting up an automatic SEO-friendly redirect for non-www versions of our URLs.

Tip

Unfortunately, by default, all pages will now be accessible with and without URLs containing index.php. In order to resolve this, we can use canonical tags—canonical tags do not contain index.php within the URL once this change has been made.

As mentioned previously, Magento comes equipped with the ability to rewrite URLs for category and product pages. Depending on the configuration we have decided upon, Magento will create entries within its core_url_rewrite table in the database to accommodate changes to the URL key of a category, a product, or the categorization of a product within our store.

In order to adjust how Magento rewrites our URLs, we can change certain options within System | Configuration | Catalog | Search Engine Optimizations as shown in the following screenshot:

Adjusting our Magento configuration for SEO

If we take a quick look at this section, we will notice that there are many options, all of which require explanation:

  • Autogenerated Site Map: If enabled, this creates two pages on our Magento website that display links to our categories and products: www.mydomain.com/catalog/seo_sitemap/category/ and www.mydomain.com/catalog/seo_sitemap/product/, respectively.
  • Popular Search Terms: This enables a page that displays your most popular search terms. This is not hugely relevant for SEO and should only be used as a tool aimed at your visitors rather than for search engines.
  • Product URL Suffix: This adds data to the end of the URL for product pages; the default is .html.
  • Category URL Suffix: This is the same as the preceding item but is meant for category pages.
  • Use Categories Path for Product URLs: With this enabled, Magento will include the category URL key within the URL structure for our product pages (for example, www.mymagento.com/category-url/product.html). When used in conjunction with Use Canonical Link Meta Tag for Products, this setting may impact our link building capabilities for our cached product pages.

    Tip

    External links built for our category-level product URLs are not automatically 301 redirected to our new canonical product URL. This can be remedied by following the Creare SEO by CreareGroup section in Chapter 8, Purpose-built Magento Extensions for SEO/CRO.

  • Create Permanent Redirect for URLs if URL Key Changed: This setting will automatically create a rewrite if we ever change the URL key attribute for a CMS, category, or product page.
  • Page Title Separator: This is a character that separates the specified page title when browsing through categories and subcategories.
  • Use Canonical Link Meta Tag for Categories: With this setting enabled, all categories will contain a new tag within their HTML instructing search engines where the primary version of the current category page can be found.
  • Use Canonical Link Meta Tag for Products: This is the same as the preceding item but will instruct the search engine to look for a primary version of any given product page.

Duplicate content is the main worry when it comes to e-commerce websites. The ability to double-categorize products is both a blessing and a curse; a blessing for users who may look for a certain product under two separate categories, but a curse for search engines, which will find identical content on two separate URLs.

Note

It is important to note that research suggests major search engines such as Google and Bing can detect when a website is classified as an e-commerce site and can make allowances for duplicate product pages.

However, it is always a good practice to ensure that, whenever possible, all steps have been taken to make this task of deducing the primary page as easy as possible for search engines.

The canonical HTML tag has been given to us for this specific purpose. It is used to point search engines to a specific URL—the URL that we want our search engine to display in the SERPs.

Here is an example of a canonical tag:

<link rel="canonical" href="http://www.mydomain.com/ottoman.html" />

For categories, the canonical tag is used to determine the static URL of that category. That is to say that when filters or pagination features are activated, the parameters appended to the URL should not be cached as separate duplicates of our category page.

In order to set up our Magento store for best optimization practice, we would want to set our configuration as follows:

  1. Navigate to System | Configuration | Catalog | Search Engine Optimizations.
  2. Set Use Categories Path for Product URLs to No.
  3. Set Use Canonical Link Meta Tag for Categories and Use Canonical Link Meta Tag for Products to Yes and then click on Save Config.
  4. Navigate to System | Index Management next to Catalog URL Rewrites and click on Reindex Data.

When we set Use Categories Path for Product URLs to No, we were telling Magento to serve our canonical product link to our users when they browse our categories. We could have set this to No even if we hadn't enabled our canonical tag for products; however, product URLs will always exist in the same two places. For example:

  • http://www.mydomain.com/furniture/living-room/ottoman.html
  • http://www.mydomain.com/ottoman.html

Ideally, we want to restrict both our users and search engines to only one version of our product page.

Restricting our users to the single URLs (without categories) will allow us to maintain consistent link-building equity for each page. Directing search engines via the canonical tag will help resolve duplicate listings in the SERPs and any algorithmic penalties attributed to duplicate content violations.