Add support for canonical links

This commit is contained in:
Noam Lerner 2023-05-22 17:03:52 +03:00
parent 01aeeee3d6
commit f1fc8b6d84
2 changed files with 12 additions and 0 deletions

View file

@ -310,6 +310,17 @@ relative to the `static` folder of your Hugo site:
All custom JS files will be added before closing body tag of a `baseof.html` file.
#### Enable User Canonical
You can specify an explicit canonical link which helps to set a single source
of truth for your page. See [here](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls#rel-canonical-link-method)
how this helps Google to crawl your page.
```toml
[Params]
enableUserCanonical = true
```
#### Entry Meta
Entry metadata are relevant information about your entry such as published date, last modified date, category, etc. You

View file

@ -21,6 +21,7 @@
{{- $cssMain := resources.Get "css/main.css" }}
{{- $cssPrint := resources.Get "css/print.css" }}
{{- $style := slice $cssReboot $cssMain $cssPrint | resources.Concat "css/bundle.css" }}
{{if site.Params.enableUserCanonical}}<link rel="canonical" href="{{ .RelPermalink }}"/>{{end}}
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
{{- range .Site.Params.customCSS }}
<link rel="stylesheet" href="{{ . | relURL }}">