From our forthcoming ebook SEO Basics for Magento Commerce (Magento 2) this extract focuses on URL Management.
A 301 redirect is the HTTP response status code for permanently redirecting URLs. This code tells the browser that one webpage has moved location from one URL to another, and will not be returning.
For example: Redirect 301 /thepixel.com/old-article.html /thepixel.com/new-article.html
Anyone typing in www.thepixel.com/old-article.html will be taken to the new home at www.thepixel.com/new-article.html.
Another type of redirect, the 302 redirect, is used when the URL of a resource is changed for a temporary period of time, such as when you're redesigning or updating a website, but you're planning on eventually bringing the page back to the existing URL. To ensure search engines and browsers of all kinds pass the same amount of link equity and credit, it's often regarded as safest to use a 301 when redirecting all URLs.
How do 301 redirects affect SEO?
Serving a 301 redirect doesn't just tell the browser, but also search engines, that the page has moved permanently. Search engines will carry any link weighting from the original page to the new URL. Discovering the 301 when first moving a page from one URL to another, and crediting the new page with the rankings and weighting of the original can take some time for search engines to execute. Because of this, transferring content becomes more complex when an entire site changes its domain or when content moves from one domain to another, as the delay can upset established page rankings.
How does Magento handle 301 redirects?
Magento will automatically create 301 redirects, for example, if you change a category or product URL, a 301 redirect will be written by default (the settings of which can be found in Search Engine Friendly URLs section below).
URL Rewrite Tool
If you wish to create additional rewrites to add high-value keywords to your product and category URLs, the URL Rewrite tool can be used. Go to Admin sidebar > Marketing > Search & SEO > URL Rewrites.
Click Add URL Rewrite, and then from the dropdown list, select Create URL Rewrite for ‘product’ or ‘category’. When selecting ‘product’ navigate to the product you want to redirect in the product grid on page (skipping the category tree). When selecting ‘category’, choose the target category you want to redirect from the category tree. You’ll then be presented with the following fields that need to be completed:
- Store: [Select the correct store if there are multiple]
- Request Path: [Enter the new URL key, eg: new-product-name.html]
- Target Path: [System version that cannot be changed]
- Redirect Type: [Permanent (301) or Temporary (302)]
- Description: [Optional description of the redirect]
The same process can also be completed for Custom Page Rewrites and CMS Page Rewrites. To create Multiple URL Rewrites for multiple or all products simultaneously, users can navigate to the Admin sidebar, Catalog > Products. Here you can select all of the products for which you want to update URL rewrites, and choose to Update attributes to update multiple or all rewrites.
There may be times when you need to create multiple permanent redirects (sometimes thousands depending on the size of the ecommerce store). Extensions for which can be found in the Magento Marketplace.
Search Engine Friendly URLs
What is a search engine friendly URL? Why use them?
SEO-friendly URLs are often short, descriptive, and keyword-rich, designed to meet both the needs of the user and search engines. The Google SEO starter guide dedicates an entire section to URLs for a very good reason: search engines use URLs to understand the context of the content on the page.
SEO-friendly URLs should contain a keyword that you want your page to rank for, and preferably, that page’s target keyword. This helps convey to search engines that this page is about a certain topic, helping identify the context of that page's content.
SEO-friendly URLs should:
- Use URLs with words that are relevant to your site’s content and structure
- Be concise with keyword selection
- Avoid excessive keyword stuffing
- Avoid using lengthy URLs with unnecessary parameters and session IDs
- Avoid choosing generic page names like blog-page1.html or /category/widget/
How can you set SEO-friendly URLs in Magento?
There are a number of different tools for configuring SEO-friendly URLs in Magento 2.
Web Server Rewrites
Go to Admin sidebar > Stores > Settings > Configuration. In the left panel under General, choose Web > Search Engine Optimization. Here you can set Use Web Server Rewrites to: Yes. The rewrite removes the file name index.php that normally appears in the URL just after the root folder, making the existing URLs easier for humans to read (since index.php conveys nothing of value to the user).
Categories Path for Product URLs
You can also set the global Search Engine Optimization configuration by going to Stores > Configuration > Catalog > Search Engine Optimization, and set the following fields:
- Use Categories Path for Product URLs: [Yes]
- Create Permanent Redirect for URLs if URL Key Changed: [Yes]
- Page Title Separator: [-]
- Use Canonical Link Meta Tag For Categories: [Yes]
- Use Canonical Link Meta Tag For Products: [Yes]