Clarification on canonical URL behavior

Hey ghost-folks,

I’m looking to use custom canonical URLs to link to external content a la “Curated lists to external sources” from and would like a little clarification before I design around this feature.

From the aforementioned blog post:

Ghost always implements automatic canonicals on every page of your site when you’re not using the custom canonical URL feature. This ensures your SEO is clean and prevents any URLs with tracking parameters from being indexed.

This makes it sound as though the custom canonical URL specified in the Ghost Editor’s “Meta Data” pane should be what’s used in the <link rel="canonical" … tag in the the page’s <head> element, but that doesn’t seem to be the case — when I publish a post with a custom canonical URL it still populates the rel="canonical" tag with the the permalink for that post on my website.

To be clear, the current behavior is what I want, I just want to make sure it’s functioning as intended and a future change to this behavior won’t break my design/SEO when I update to a new version of Ghost.

tl;dr: I want to be able to use {{canonical_url}} to link to external content and still have the rel="canonical" in that page’s <head> element use the post’s permalink. Things currently work this way but the documentation seems to indicate it shouldn’t, I’d like some clarification before designing around this behavior.

Thank you!

Hey @magnolialogic, just want clarify this:
So you’ve put a link into the ‘Canonical URL’ field within your post, however when you go to view the post the content of the canonical meta tag contains the actual URL of the post that’s being viewed? Have I got that right? If so then that sounds like a bug.

If you want to link to an external source but not affect the canonical URL then you should add the URL in another way

Yeah, that’s what I’m seeing. Damn, I was hoping that was an error in the documentation :confused:

Thanks for the info, you saved me a lot of heartburn somewhere down the road when this bug gets fixed.

Is there another way to provide a linked URL that I could access from a helper in my theme? The idea is to have the title of some posts link out to external content and add a “permalink” icon or image to link to the post’s page itself, e.g. linking to {{canonical_url}} for the title and {{url}} with the permalink icon.

So, to clarify, you want to be able to link to an external page as well as the post on your site? You could use the code inject option in each post to paste in a url

You could then pick it up with JavaScript, or customise your theme to use it directly in the template

1 Like