Canonicalisation - How do I tell Google the content is sourced elsewhere?

I have the same content on two websites. I would like to use the frontmatter within Hugo to point to the original source of the content (on my other website).

I’ve tried Aliases but it’s informing me (and rightly so) only relative aliases are supported.

Any idea how this can be done?

Repo below (not sure it’s needed).

Not a good answer, but .htaccess (or netlify redirects or …) seems to be a better solution.

If your really want your solution:

  • add a param in your header
  • in the single.html template, something like:
  • if param redirect exists > partial like hugo redirect template
  • else the normal single page
1 Like

Hi Maiki

Thanks for your help. I understand canonicalisation, and its the exact reason why I asked the question. SEO purposes mostly.

Simply not sure how to add a canonical link to the frontmatter of a blog post.

Front matter is whatever you want, aside from predefined variables, right? I’d probably name it canonicalurl or something. Then, wherever you load the metadata in the head element of your pages from your templates, use with to include the link element.

Hmmm, I’m not familiar with your way of asking questions. You said:

  • Canonicalisation - How do I tell Google the content is sourced elsewhere?
  • Any idea how this can be done?

It sounded like you were asking about the concept. Correct me if I misunderstand again, but I think you are asking about adding the canonical link element to a page based on front matter. The above instructions, along with the linked docs, will provide that. If it is something else, I’ll let another person jump in. :slight_smile:


1 Like

Cheers for your help and advice around Frontmatter. I’ll get to work today implementing your feedback.