Add showCanonicalLink
to markdown metadata (#428)
If an article has a `canonicalUrl` set, Originally published at `<hostname>` will be displayed at the top of the article by setting `showCanonicalLink` to true. Usage => In front-matter: canonicalUrl: "<URL>" showCanonicalLink: true
This commit is contained in:
parent
a57cb762c3
commit
38891b9062
@ -17,6 +17,7 @@
|
||||
{{- partial "post_meta.html" . -}}
|
||||
{{- partial "translation_list.html" . -}}
|
||||
{{- partial "edit_post.html" . -}}
|
||||
{{- partial "post_canonical.html" . -}}
|
||||
</div>
|
||||
{{- end }}
|
||||
</header>
|
||||
|
9
layouts/partials/post_canonical.html
Normal file
9
layouts/partials/post_canonical.html
Normal file
@ -0,0 +1,9 @@
|
||||
{{ if and (.Params.canonicalURL) (.Params.ShowCanonicalLink ) -}}
|
||||
{{ $url := urls.Parse .Params.canonicalURL }}
|
||||
|
||||
{{- if or .Params.author $.Site.Params.author (.Param "ShowReadingTime") (not .Date.IsZero) .IsTranslated (or .Params.editPost.URL .Site.Params.editPost.URL) }} | {{- end -}}
|
||||
<span>
|
||||
{{- (.Site.Params.CanonicalLinkText | default .Params.CanonicalLinkText) | default "Originally published at" -}}
|
||||
<a href="{{ trim .Params.canonicalURL " " }}" title="{{ trim .Params.canonicalURL " " }}" target="_blank" rel="noopener noreferrer">{{ $url.Host }}</a>
|
||||
</span>
|
||||
{{- end }}
|
Loading…
Reference in New Issue
Block a user