<p>Global category content canonical URL pattern seems to set og:url, but not the canonical one. I've tried replacing <code>@web</code> with the address proper without any change. I suspect I've misconfigured something.</p>
<p>The category group's URL pattern is: <code>product-categories/{slug}</code>,
and it's canonical URL in content SEO is: <code>@web/products/{category.slug}</code>.
A custom route loads the template: <code>products/{tag}</code>.
Which does a: <code>seomatic.helper.loadMetadataForUri(category.uri)</code>.</p>
<p>However,</p>
<p>In a category's SEO preview the canonical URL is still <code>product-categories/{slug}</code>.
While in the header of a <code>product/{category}</code> page the canonical URL link isn't present.</p>
<p>Adding a link with <code>seomatic.link.create({&quot;rel&quot;: &quot;canonical&quot;,&quot;href&quot;: canonicalUrl,})</code> works like a charm.</p>

CC BY-SA 4.0
2020-08-10T13:25:43.870Z
What do you have the Canonical URL set to in Content SEO for your Category Group?
andrew.welch
CC BY-SA 4.0
2020-08-10T21:21:07.587Z
That's that `@web/products/{category.slug}`.
ponies
CC BY-SA 4.0
2022-03-07T12:58:36.163Z
Old question, I know, but still. Have you tried using `{% do seomatic.meta.canonicalUrl( seomatic.helper.safeCanonicalUrl() ) %}`
InanisAtheos
<plugin-seomatic>
Set category's canonical URL on a custom route
# Set category's canonical URL on a custom route

(Asked by: username_0 on 2020-08-06)

Global category content canonical URL pattern seems to set og:url, but not the canonical one. I've tried replacing `@web` with the address proper without any change. I suspect I've misconfigured something.

The category group's URL pattern is: `product-categories/{slug}`,
and it's canonical URL in content SEO is: `@web/products/{category.slug}`.
A custom route loads the template: `products/{tag}`.
Which does a: `seomatic.helper.loadMetadataForUri(category.uri)`.

However,

In a category's SEO preview the canonical URL is still `product-categories/{slug}`.
While in the header of a `product/{category}` page the canonical URL link isn't present.

Adding a link with `seomatic.link.create({"rel": "canonical","href": canonicalUrl,})` works like a charm.

**Tags:** plugin-seomatic
> **Comments:**
> **username_1**: What do you have the Canonical URL set to in Content SEO for your Category Group?  
> **username_0**: That's that `@web/products/{category.slug}`.  
> **username_2**: Old question, I know, but still. Have you tried using `{% do seomatic.meta.canonicalUrl( seomatic.helper.safeCanonicalUrl() ) %}`  

---

## 0 answers

