craft-seomatic icon indicating copy to clipboard operation
craft-seomatic copied to clipboard

Canonical override missing in graphql response

Open remoflury opened this issue 4 months ago • 2 comments

Describe the bug

When a canonical override on a page entry is set, the gql response does not contain the rel="canonical" tag.

To reproduce

Steps to reproduce the behaviour:

  1. Set a canonical override in your page entry SEOmatic field
  2. query the page's seomatic with gql: query page($uri: String) { seomatic(uri: $uri) { metaTitleContainer metaTagContainer } }
  3. Have a look at the response.
  4. (optional): Set "Always include canonical links regardless of environment" in plugins setting to true -> does not change the outcome. (environment in my case is manually set to live)

Expected behaviour

A correct canonical tag in the metaTagContainer

Versions

  • Plugin version: 5.1.19
  • Craft version: 5.8.20

remoflury avatar Dec 04 '25 10:12 remoflury

Can you provide me with a screenshot of the SEO Settings field that has the Canonical URL override set?

khalwat avatar Dec 09 '25 03:12 khalwat

@khalwat

Image

remoflury avatar Dec 09 '25 19:12 remoflury

And this entry is populated to all sites? Or is it a per-site entry? Just trying to get enough information to reproduce it here locally.

khalwat avatar Dec 12 '25 22:12 khalwat

@khalwat this is a seomatic field, which was placed into a page (section). therefore you have access to the seo settings for each page individually, which works fine for other fields inside the seomatic field (e.g. title, description).

So if i have two pages, i can overrride the titles etc. on each entry individually. this works fine, except for the canonical url

remoflury avatar Dec 13 '25 07:12 remoflury

Do you have anything configured in the URL Override setting in SEOmatic?

Image

SEOmatic -> Plugin Settings -> Advanced -> Site URL Override

khalwat avatar Dec 13 '25 22:12 khalwat

So I think this isn't actually a bug. The canonical URL is not contained in the metaTagContainer but rather the metaLinkContatiner (because it's a <link rel="">).

So try:

query page($uri: String) {
  seomatic(uri: $uri) {
    metaTitleContainer
    metaTagContainer
    metaLinkContainer
  }
}

I tested it with the URL being overriden via an SEO Settings field in and entry, and it worked as expected for me.

khalwat avatar Dec 13 '25 22:12 khalwat