Configure Hreflang Link Groups for Products in Magento 2
New in v2.3.0: This feature extends the existing CMS page grouping functionality to products and categories, allowing you to manually override automatic hreflang linking.
This guide explains how to use Alternate Link Groups in the Alternate Hreflang Extension to manually link products or categories across stores when automatic linking doesn't fit your needs.
How Automatic Linking Works
By default, the module automatically links entities across stores:
| Entity Type | Automatic Linking Method |
|---|---|
| Products | Same product ID/SKU across store views in the same targeting group |
| Categories | Same category ID across store views in the same targeting group |
| CMS Pages | No automatic linking (always requires manual grouping) |
Targeting groups are configured in:
Stores > Configuration > Magmodules > Alternate Hreflang > Targeting Settings
When to Use Alternate Link Groups
Use manual Alternate Link Groups when:
- Different products should link together - e.g., "Blue T-Shirt" (US) should link to "T-Shirt Bleu" (FR) which are different products
- Different categories should link together - e.g., "Clothing" (US) should link to "Vêtements" (FR) which are different categories
- Products/categories exist only in certain stores - linking regional variants that don't share the same ID
- Override automatic linking - when the default ID-based linking isn't correct for your use case
Finding the Alternate Link Group Field
Products
- Navigate to Catalog > Products
- Edit any product
- Scroll to Hreflang Override section
- Find the Alternate Link Group field
Categories
- Navigate to Catalog > Categories
- Select any category
- Scroll to Hreflang Override section
- Find the Alternate Link Group field
Using the Dropdown
The dropdown contains two sections:
Actions
- Use automatic linking (default) - Product/category uses standard ID-based linking
- Create new group - Shows input field to create a new group name
Existing Groups
Lists all previously created group names. Select one to add the product/category to that group.
Step-by-Step Example: Products
Scenario
You have different products in each store that should be treated as translations:
| Store | Product | SKU |
|---|---|---|
| US (en-us) | Blue Running Shoes | SHOE-US-001 |
| France (fr-fr) | Chaussures de Course Bleues | SHOE-FR-001 |
| Germany (de-de) | Blaue Laufschuhe | SHOE-DE-001 |
These are different products (different SKUs) but represent the same item in different markets.
Solution
Step 1: Create group on first product
- Edit "Blue Running Shoes" (US store)
- Go to Hreflang Override section
- Select Create new group from dropdown
- Enter group name:
running-shoes-blue - Save product
Step 2: Add other products to the group
- Edit "Chaussures de Course Bleues" (FR store)
- Go to Hreflang Override section
- Select
Running-shoes-bluefrom Existing Groups - Save product
Repeat for German product.
Result:
All three products now link to each other with hreflang tags:
<link rel="alternate" hreflang="en-us" href="https://example.com/blue-running-shoes" />
<link rel="alternate" hreflang="fr-fr" href="https://example.fr/chaussures-course-bleues" />
<link rel="alternate" hreflang="de-de" href="https://example.de/blaue-laufschuhe" />
Step-by-Step Example: Categories
Scenario
Different category structures per store:
| Store | Category | ID |
|---|---|---|
| US (en-us) | Men's Apparel | 42 |
| France (fr-fr) | Vêtements Homme | 156 |
| Germany (de-de) | Herrenkleidung | 89 |
Different category IDs, but same conceptual category.
Solution
- Edit each category
- Select or create group:
mens-clothing - Save
All three categories now have hreflang tags linking to each other.
Group Naming Best Practices
Good Names
mens-clothing- descriptiverunning-shoes-blue- specific product type + variantelectronics-smartphones- category hierarchyhomepage- standard page type
Avoid
group1,test- not descriptiveenglish-product- language in name (group is for ALL languages)- Spaces or special characters - use hyphens
Important Notes
Overriding Automatic Linking
When you assign a product/category to an Alternate Link Group:
- Automatic ID-based linking is disabled for that entity
- Only entities in the same group will link to each other
- Entities without a group continue using automatic linking
Store View Scope
The Alternate Link Group field is store view scoped:
- Set different values per store view if needed
- Typically, you'll set the same group name across all store views for the same logical entity
Clearing Groups
To remove a product/category from a group and return to automatic linking:
- Edit the entity
- Select Use automatic linking (default)
- Save
Verifying Your Setup
Using Debug Mode
- Enable debug mode in module configuration
- Visit the product/category page with
?show-alternate=1 - Verify the hreflang tags show correct alternate URLs
Example:
https://example.com/blue-running-shoes?show-alternate=1
Common Issues
Tags not appearing:
- Check that all grouped entities have the exact same group name
- Verify entities are assigned to correct store views
- Clear cache after changes
Wrong products/categories linked:
- Check for typos in group names
- Verify you selected the correct existing group
Relationship with CMS Pages
CMS pages have always required manual grouping (they have no automatic linking). The same Alternate Link Group concept now works for products and categories too.
Migration from Automatic Linking
If you're currently using automatic linking and want to switch to manual groups:
- Identify entities that need manual grouping
- Create naming scheme for your groups
- Update entities one group at a time
- Test with debug mode after each group
- Clear cache to see changes
Summary
| Feature | Automatic Linking | Alternate Link Groups |
|---|---|---|
| Based on | Same ID/SKU | Group name |
| Setup | None required | Manual assignment |
| Use case | Standard multi-store | Different IDs, same content |
| Products | Default behavior | Override when needed |
| Categories | Default behavior | Override when needed |
| CMS Pages | Not available | Always required |
Need More Help?
Documentation:
- All Help Articles - Complete documentation
Support:
- Contact Support - Get help from our team