Shopware SEO URL template explained: how product URLs are created
The Shopware SEO URL template defines what the URL of every product page looks like. Shopware does not maintain product URLs one by one but calculates them from a Twig template, per sales channel and language. Once you understand the template, you also understand why URLs sometimes stay the same after a change and how old links are kept via 301. At the end you see how the two-generator system of PIM for Shopware builds on it.
- One Twig template per page type, global or per sales channel, creates the URLs of all products.
- If a path changes, the old URL stays as a redirect.
- URLs marked as manually modified are not overwritten by Shopware's indexer.
- The PIM first writes the path into a custom field and then stores a template that reads this field.
What the SEO URL template in Shopware is
In Shopware you find the templates under Settings → Shop → SEO. For every page type, such as product detail page and category page, there is a template that applies to all sales channels or is overridden for a single channel. The default template for products is:
{{ product.translated.name }}/{{ product.productNumber }}
For every product in every sales channel and language Shopware fills in the values and stores the result as the SEO URL. "Hiking boot Alpine" with number SW1001 thus becomes a path like Hiking-boot-Alpine/SW1001. Because the template is Twig, conditions are possible too, for example a custom field that is only used when it is filled.
Output, special characters and uniqueness
Shopware treats every variable output as part of a URL path and converts spaces and special characters. That is handy for names but becomes a problem when a field already contains a whole path with slashes: the slashes would be converted as well. For such fields the output needs the |raw filter.
A path must be unique per sales channel and language. The same URL in two different shops is not a problem. If two products in the same channel and language produce the same path, only one can get it. A template that outputs only the name is therefore risky for variants or products with the same name.
Reindexing, canonical URL and 301
Per product, channel and language there is exactly one canonical URL, i.e. the currently valid one. If the path changes, for example because the name or the template was changed, Shopware creates a new canonical URL and keeps the old one as an entry that redirects to the new one. This way old links and search engine results do not lead nowhere.
URLs are recalculated when Shopware indexes the products, for example after a product is saved or during a full reindex. A changed template therefore only affects existing products once they are reindexed. URLs marked as manually modified are left alone by the indexer. This protects hand-maintained URLs, but it is also the most common reason why a new template seems not to apply to some products.
Shopware SEO URL template in the PIM: the two-generator system
The Twig template alone reaches its limits when URLs should contain a full category path, variant options and clean translations. PIM for Shopware therefore splits the job into two steps. You find both in the config matrix in the "SEO URLs" tab.
Step 1: generate the URL in a custom field
A token pattern such as {mainCategoryPath}/{name}-{options} is resolved per main product, variant and language and written to the custom field staw_pim_canonical, optionally into a separate field per shop. The category path follows the channel's SEO main category, missing translations fall back to the parent language and then to the system language. Umlauts are transliterated, double separators are merged.
Step 2: generate SEO URLs with Twig
A Twig pattern reads this custom field, and the output automatically gets |raw. When generating, the PIM stores the pattern per chosen shop as Shopware's SEO URL template of the product detail page and lets Shopware's own generator create the URLs. Because the template is then stored in Shopware, every later reindex produces the same URLs. If the pattern outputs nothing for a product, Shopware uses the product name instead of an empty path.
Options, preview and dry run
In the generation window you choose shops and languages. "Keep old URLs as 301" and "Only generate missing SEO URLs" are on by default, and a reset optionally removes all product URLs of the selection first. The preview shows up to three sample products with old and new path, the dry run calculates everything without writing and reports conflicts. The editor checks the Twig syntax continuously and warns if tokens such as {name} appear in the Twig pattern.
Console and Shopware standard
For large catalogues the command staw:pim:seo:generate creates the URLs of a channel directly on the server and marks them as manually modified so the indexer does not overwrite them. If you prefer to maintain single URLs by hand, switch on "Use Shopware standard SEO URL" and edit the native URL per product in the PIM. The two generators are then off.
Step by step: build product URLs with a category path
- Check main categories: set the SEO main category for every channel, via bulk edit in the SEO tab if needed.
- Define the token pattern: enter a pattern such as {mainCategoryPath}/{name}-{options} in step 1 and check the preview in all languages.
- Fill the custom field: start "Generate URL in custom field" for the desired shops and languages.
- Store the Twig pattern: use the canonical field as the output in step 2.
- Dry run: let the run calculate with "Keep old URLs as 301" as a test and resolve reported conflicts.
- Generate: start "Generate SEO URLs" and check a few product pages in the storefront.
Use cases
- Shop migration: take over existing URLs from a custom field of your own, new products get the PIM path. The Twig condition for migrated URLs is prepared as a button in the editor.
- Multilingual shops: separate paths per language from translated names and categories.
- Variant pages: {options} makes each variant with its own URL unique.
- Category restructuring: create new paths while old URLs remain reachable as redirects.
Frequently asked questions
What is the SEO URL template in Shopware?
A Twig template per page type from which Shopware calculates the URLs of all products or categories. You maintain it under Settings → Shop → SEO, globally or per sales channel.
Why do URLs not change immediately after a new template?
Existing products only get new URLs at the next indexing. URLs marked as manually modified are not overwritten by the indexer.
Are old links lost when a URL changes?
No. The old URL is kept as an entry that redirects to the new canonical URL. In the PIM the option "Keep old URLs as 301" controls this.
Why do I need |raw in the template?
Shopware converts special characters in every output, including slashes. If a field contains a whole path, |raw prevents it from turning into hyphens. The PIM adds |raw for its fields automatically.
Do the URLs from the PIM survive a reindex?
Yes. The PIM stores its pattern as the SEO URL template in Shopware, so a reindex produces the same URLs.
Read more
- SEO URLs in PIM for Shopware: guide - all variables and options
- Generate and change Shopware SEO URLs - rebuild URLs
- Shopware category SEO and category texts - categories for the path
- AI SEO texts for Shopware meta data - meta title and meta description
- Config matrix in PIM for Shopware: guide - SEO URLs tab
Try PIM for Shopware
All licence models and terms are listed on the pricing page. Want to know up front whether the PIM fits your shop and your processes? Get in touch via the contact form - we answer personally.