-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add canonical URL to blog posts
Used some code from PaperMod
- Loading branch information
1 parent
e334587
commit e7193e7
Showing
7 changed files
with
122 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{ define "main" }} | ||
<article class="mt-10 flex flex-col items-center justify-center"> | ||
<nav class="place-self-start"> | ||
<a href="{{ "" | relURL }}" class="text-neutral-500">← {{ i18n "nav.home" }}</a> | ||
</nav> | ||
<header> | ||
<h1 class="mb-6 mt-2 text-center text-4xl font-extrabold text-neutral-800 dark:text-white"> | ||
{{ .Title | emojify }} | ||
</h1> | ||
<h3>{{- partial "post_canonical.html" . -}}</h3> | ||
</header> | ||
<section class="prose dark:prose-invert"> | ||
{{ .Content | emojify }} | ||
</section> | ||
</article> | ||
{{ end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<head> | ||
<meta charset="utf-8" /> | ||
{{ with .Site.LanguageCode }} | ||
<meta http-equiv="content-language" content="{{ . }}" /> | ||
{{ end }} | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge" /> | ||
{{/* Title */}} | ||
{{ if .IsHome -}} | ||
<title>{{ .Site.Title }}</title> | ||
<meta name="title" content="{{ .Site.Title }}" /> | ||
{{- else -}} | ||
<title>{{ .Title | emojify }} · {{ .Site.Title | emojify }}</title> | ||
<meta name="title" content="{{ .Title | emojify }} · {{ .Site.Title | emojify }}" /> | ||
{{- end }} | ||
{{/* Metadata */}} | ||
{{ with .Params.Description -}} | ||
<meta name="description" content="{{ . }}" /> | ||
{{- else -}} | ||
<meta name="description" content="{{ $.Site.Params.Description }}" /> | ||
{{- end }} | ||
{{ with .Site.Params.keywords -}} | ||
<meta name="keywords" content="{{ . }}" /> | ||
{{- end }} | ||
{{ with .Site.Params.robots }} | ||
<meta name="robots" content="{{ . }}" /> | ||
{{ end }} | ||
{{ with .Params.robots }} | ||
<meta name="robots" content="{{ . }}" /> | ||
{{ end }} | ||
<link rel="canonical" href="{{ if .Params.canonicalURL -}} {{ trim .Params.canonicalURL " " }} {{- else -}} {{ .Permalink }} {{- end }}"> | ||
{{ range .AlternativeOutputFormats -}} | ||
{{ printf `<link rel="%s" type="%s" href="%s" title="%s" />` .Rel .MediaType.Type .RelPermalink $.Site.Title | safeHTML }} | ||
{{ end -}} | ||
{{/* Asset bundles */}} | ||
{{ $assets := newScratch }} | ||
{{ $cssMain := resources.Get "css/compiled/main.css" }} | ||
{{ $assets.Add "css" (slice $cssMain) }} | ||
{{ $cssCustom := resources.Get "css/custom.css" }} | ||
{{ if $cssCustom }} | ||
{{ $assets.Add "css" (slice $cssCustom) }} | ||
{{ end }} | ||
{{ $bundleCSS := $assets.Get "css" | resources.Concat "css/main.bundle.css" | resources.Minify | resources.Fingerprint "sha512" }} | ||
<link | ||
type="text/css" | ||
rel="stylesheet" | ||
href="{{ $bundleCSS.RelPermalink }}" | ||
integrity="{{ $bundleCSS.Data.Integrity }}" | ||
/> | ||
{{/* Icons */}} | ||
{{ if templates.Exists "partials/favicons.html" }} | ||
{{ partialCached "favicons.html" .Site }} | ||
{{ else }} | ||
<link rel="apple-touch-icon" sizes="180x180" href="{{ "apple-touch-icon.png" | relURL }}" /> | ||
<link rel="icon" type="image/png" sizes="32x32" href="{{ "favicon-32x32.png" | relURL }}" /> | ||
<link rel="icon" type="image/png" sizes="16x16" href="{{ "favicon-16x16.png" | relURL }}" /> | ||
<link rel="manifest" href="{{ "site.webmanifest" | relURL }}" /> | ||
{{ end }} | ||
{{/* Site Verification */}} | ||
{{ with .Site.Params.verification.google }} | ||
<meta name="google-site-verification" content="{{ . }}" /> | ||
{{ end }} | ||
{{ with .Site.Params.verification.bing }} | ||
<meta name="msvalidate.01" content="{{ . }}" /> | ||
{{ end }} | ||
{{ with .Site.Params.verification.pinterest }} | ||
<meta name="p:domain_verify" content="{{ . }}" /> | ||
{{ end }} | ||
{{ with .Site.Params.verification.yandex }} | ||
<meta name="yandex-verification" content="{{ . }}" /> | ||
{{ end }} | ||
{{/* Social */}} | ||
{{ template "_internal/opengraph.html" . }} | ||
{{ template "_internal/twitter_cards.html" . }} | ||
{{/* Generator */}} | ||
{{ if .Site.Params.attribution | default true }} | ||
{{ hugo.Generator }} | ||
{{ end }} | ||
{{/* Me */}} | ||
{{ with .Site.Author.name }}<meta name="author" content="{{ . }}" />{{ end }} | ||
{{ with .Site.Author.links }} | ||
{{ range $links := . }} | ||
{{ range $name, $url := $links }}<link href="{{ $url }}" rel="me" />{{ end }} | ||
{{ end }} | ||
{{ end }} | ||
{{/* Analytics */}} | ||
{{ partialCached "analytics.html" . }} | ||
{{/* Extend head - eg. for custom analytics scripts, etc. */}} | ||
{{ if templates.Exists "partials/extend-head.html" }} | ||
{{ partialCached "extend-head.html" .Site }} | ||
{{ end }} | ||
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<!-- https://github.com/adityatelange/hugo-PaperMod/blob/3f50861a0ced88f9b614a43662edeb4c0bc45da8/layouts/partials/post_canonical.html --> | ||
{{ if .Params.canonicalURL -}} | ||
{{ $url := urls.Parse .Params.canonicalURL }} | ||
<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" style="text-decoration: underline;">{{ $url.Host }}</a> | ||
</span> | ||
{{- end }} |