Hugo

How to replace the href value of the <link rel="canonical"...>

Each page generates a <link rel="canonical"> in the <head>. I’d like to replace what HUGO generates for that tag with my own “canonical” link tag (I have an absolute href for that tag that is on a completely different domain).

I tried adding my own parameter in the front matter (canonical_href) and then templated that into the head of the single template but that just created a duplicate <link rel="canonical"...> tag which google doesn’t like.

So, is there a way to control what HUGO does in the regarding the <link rel="canonical"...> tag?

I use the latest 0.13-DEV, but I cannot see (or reproduce) where Hugo inserts that canonical link. Are you sure this isn’t part of your template?

Wow, brilliant. You are correct, I created that very line of code that does that:

<link rel="canonical" href="{{ .Permalink }}">

I should have looked there. Silly me!