feat: add canonical url support (#650)
When you want to publish content that is already published on a different site. You need to reference a canonical url of the original content. By defining the `canonicalUrl` in the front matter definition the canonical url is set in the headers.
This commit is contained in:
parent
4ea29d886c
commit
221a0d8817
|
@ -334,6 +334,14 @@ Dates of blog posts and single pages are rendered with the default date format c
|
|||
With hugo 0.87.0 and above, you can also use predefined layout, like `:date_full`, and it will output localized dates or times.
|
||||
See hugo's documentation of the [`time.Format` function](https://gohugo.io/functions/dateformat/) for more details.
|
||||
|
||||
### Using a canonical url
|
||||
|
||||
When you want to publish content that is already published on a different site. You need to reference a canonical url of the original content.
|
||||
By defining the `canonicalUrl` in the front matter definition the canonical url is set in the headers.
|
||||
|
||||
```
|
||||
canonicalUrl: https://mydomain.com/path-to-the-oringinal-content/
|
||||
```
|
||||
|
||||
### Nearly finished
|
||||
|
||||
|
|
|
@ -31,6 +31,12 @@
|
|||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ if .Params.canonicalUrl }}
|
||||
<link rel="canonical" href="{{ .Params.canonicalUrl }}">
|
||||
{{ else }}
|
||||
<link rel="canonical" href="{{ .Permalink }}">
|
||||
{{ end }}
|
||||
|
||||
{{/* NOTE: These Hugo Internal Templates can be found starting at https://github.com/gohugoio/hugo/tree/master/tpl/tplimpl/embedded/templates */}}
|
||||
{{- template "_internal/opengraph.html" . -}}
|
||||
{{- template "_internal/schema.html" . -}}
|
||||
|
|
Loading…
Reference in a new issue