Skip to content

Commit

Permalink
feat: add canonical to head.html (#269)
Browse files Browse the repository at this point in the history
By adding `canonical` parameter to the front matter and specifying the URL, the canonical URL is added. 
If no canonical URL is needed to be specified, the layout will use the current page address for canonical tag. 

Example: 

```
---
title: "Page Title"
description: "Page description"
canonical: "https://canonicalurl.com"
---
  • Loading branch information
mafendi authored Feb 1, 2024
1 parent fbe1aac commit cb274c8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion layouts/partials/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@
{{ end -}}
</title>
<meta name="description" content="{{ partial "utils/page-description.html" . }}" />
<link rel="canonical" href="{{ .Permalink }}">

{{ with .Params.canonical }}
<link rel="canonical" href="{{ . }}" itemprop="url" />
{{ else }}
<link rel="canonical" href="{{ .Permalink }}" itemprop="url" />
{{ end }}

{{ partial "opengraph.html" . }}
{{ template "_internal/schema.html" . -}}
Expand Down

0 comments on commit cb274c8

Please sign in to comment.