Permalinkable and permalink in AMP of canonical link

After 0.55 all the AMP pages with {{ .permalink }} have /amp/ in them, so, for example, the canonical link in an AMP page with:

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

renders as

<link rel="canonical" href="http://localhost:1313/amp/blog/some-page/"/>

which is wrong, there shouldn’t be /amp/ in there, how should I get a permalink of the current page without the amp in it?

You can list alternative formats:

{{ range .AlternativeOutputFormats }}
    <link rel="{{ .Rel }}" type="{{ .MediaType.Type }}" href="{{ .Permalink }}">
{{ end }}

It also works the other way - to list amp version from you canonical version

2 Likes