Search…
Magento 2 Alternate Hreflang Tags

Installation and User Guide for Magento 2 Alternate Hreflang Tags

Table of Contents
  1. 1.
    • Installation via app/code
    • Installation via Composer
  2. 2.
  3. 3.
    • General Settings
    • Language and Country Settings
  4. 5.
    • Category Page
    • Product Page
    • CMS Page
  5. 7.
    • Hreflang Tag on the Home Page
    • Hreflang Tag on the Category Page
    • Hreflang Tag on the Product Page
    • Hreflang Tag on the CMS Page

Installation

  • Installation via app/code: Upload the content of the module to your root folder. This will not overwrite the existing Magento folder or files, only the new contents will be added. After the successful upload of the package, run below commands on Magento 2 root directory.
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy
  • Installation via Composer: Please follow the guide provided in the below link to complete the installation via composer.

Configuration Settings for SEO Base

Go to Admin > Stores > Configuration > Scommerce Configuration > SEO Base

General Settings

  • Enabled – Select “Yes” or “No” to enable or disable the module.
  • License Key – Please add the license for the extension which is provided in the order confirmation email. Please note license keys are site URL specific. If you require license keys for dev/staging sites then please email us at [email protected]

Configuration Settings for Alternate Hreflang

Go to Admin > Stores > Configuration > Scommerce Configuration > Hreflang

General Settings

  • Enable - Select “Yes” or “No” to enable or disable the module.
  • X-Default – Select default store view.
  • Enable Hreflang Tags for Categories – Select “Yes/No”. If set to “Yes” then it will enable Hreflang Tags for the categories.
  • Enable Hreflang Tags for Products – Select “Yes/No”. If set to “Yes” then it will enable Hreflang Tags for the products.
  • Enable Hreflang Tags for CMS Pages – Select “Yes/No”. If set to “Yes” then it will enable Hreflang Tags for the CMS Pages.

Language and Country Settings

  • Select Language – Select local or custom languages from the drop-down list.
  • Add Country – Select “Yes/No”. If set to “Yes” then only the “Select Country” option will be visible.
  • Select Country – Select country from the drop-down list.

Set Path Priority

We have a priority system in place for the URL path that is to be included in the sitemap. The URL path is picked based on the below priority system:-
  • Override canonical URL:- It is of highest priority. If this is set for any product, category or CMS page then canonical URL path will be picked in the hreflang tag.
  • Set Primary Category:- It is secondest highest priority. If override canonical URL is not set then the primary category path set is picked in the hreflang tag.
  • Default Path:- if neither override canonical URL nor Set primary Category is set then the default path of the product, category or CMS page is picked to be included in the hreflang tag.

Override Canonical URL

You can set the override canonical URL for any product, category or CMS page. The steps to setup override canonical URL is provided as below:-

Category Page

Go to Admin>Catalog>Categories and select any category. Scroll down to find the tab "Search Engine Optimization". Enter the URL path in the "Override Canonical URL" section.

Product Page

Go to Admin>Catalog>products and select any product and click edit. Scroll down to find the tab "Search Engine Optimization". Enter the URL path in the "Override Canonical URL" section.

CMS Page

Go to Admin>Content>Pages and select any page. Scroll down to find the tab "Search Engine Optimization". Enter the URL path in the "Override Canonical URL" section.

Set Primary Categories

You can use a script provided with the extension to automatically add primary categories for products. Admin can exclude certain categories from primary category and also prioritise one category over the other to be picked as the primary category.
Go to Admin>Catalog>Categories select a category then scroll down to find the option "Primary Category Settings". Here click on "Exclude From Primary Category" to exclude this category from primary category or enter the priority 0 being the highes. The highest priority category will be picked first for the primary category.
To automatically assingn primary category for all products run the command given below by going into the root directory of your store.
scommerce:seo-base:set-primary-category
N.B - If you are using older version then run the script provided in the extension folder at the path Data/SetPrimaryCategoryM2.php from ssh

Front-end Site view

  • Hreflang Tag on the Home Page - You can enable hreflang on the home page by selecting "Yes" for " Hreflang Tags For CMS Pages " from Admin > Stores > Configuration > Scommerce Configuration > Hreflang > General Settings > Enable - Select "Yes " > Enable Hreflang Tags For CMS Pages.
  • Hreflang Tag on the Category Page - To enable hreflang on the category page, go to Admin > Stores > Configuration > Scommerce Configuration > Hreflang > General Settings > Enable - Select "Yes " > Enable Hreflang Tags For Categories - "Yes".
  • Hreflang Tag on the Product Page - You can enable hreflang on the product page by selecting "Yes" for " Hreflang Tags For Products " from Admin > Stores > Configuration > Scommerce Configuration > Hreflang > General Settings > Enable - Select "Yes " > Enable Hreflang Tags For Products.
  • Hreflang Tag on the CMS Page - Enable hreflang on the CMS Pages From Admin > Stores > Configuration > Scommerce Configuration > Hreflang > General Settings > Enable - Select "Yes " > Enable Hreflang Tags For CMS Pages - "Yes". Go to Admin > content > Pages select the about us page for each store view and go into Search Engine Optimization. Put the same identifier if you want interlinking between various languages of the same about us page.
If you have a question related to this extension please check out our FAQ section first. If you can't find the answer you are looking for then please contact [email protected].
Export as PDF
Copy link
On this page
Installation and User Guide for Magento 2 Alternate Hreflang Tags
Installation
Configuration Settings for SEO Base
Configuration Settings for Alternate Hreflang
General Settings
Set Path Priority
Override Canonical URL
Set Primary Categories
Front-end Site view