test-cross-blogger/layouts/partials/post_canonical.html

13 lines
807 B
HTML
Raw Permalink Normal View History

{{ if and .Params.canonicalURL (or .Params.ShowCanonicalLink site.Params.ShowCanonicalLinks) -}}
<!-- https://gohugo.io/functions/urls/parse/ -->
{{ $url := urls.Parse .Params.canonicalURL }}
<!-- https://gohugo.io/functions/strings/replacere/ -->
{{ $urlWithoutScheme := replaceRE "^https?://" "" $url.String }}
{{- if or .Params.author site.Params.author (.Param "ShowReadingTime") (not .Date.IsZero) .IsTranslated (or .Params.editPost.URL site.Params.editPost.URL) }}&nbsp;|&nbsp;{{- end -}}
<span>
{{- (site.Params.CanonicalLinkText | default .Params.CanonicalLinkText) | default "Originally published at" -}}
&nbsp;<a href="{{ trim .Params.canonicalURL " " }}" title="{{ trim .Params.canonicalURL " " }}" target="_blank" rel="noopener noreferrer">{{ $urlWithoutScheme}}</a>
</span>
{{- end }}