Ver código fonte

Add support for canonical links (#1001)

Co-authored-by: Emruz Hossain <hossainemruz@gmail.com>
David G. Simmons 6 meses atrás
pai
commit
2f670db6a0
2 arquivos alterados com 5 adições e 2 exclusões
  1. 1 1
      layouts/_default/baseof.html
  2. 4 1
      layouts/_default/single.html

+ 1 - 1
layouts/_default/baseof.html

@@ -8,7 +8,7 @@
     {{ template "_internal/twitter_cards.html" . }}
     <!------ ADD PAGE SPECIFIC HEADERS ------->
     {{ block "header" . }} {{ end }}
-
+    
     <!--================= add analytics if enabled =========================-->
     {{- partial "analytics.html" . -}}
     <script>

+ 4 - 1
layouts/_default/single.html

@@ -1,5 +1,8 @@
 {{ define "header" }}
 <meta name="description" content="{{ if .Description }}{{ .Description }}{{ else }}{{ .Title }}{{ end }}" />
+{{ with .Params.relcanonical }}
+<link rel="canonical" href="{{ . | relLangURL }}" itemprop="url" />
+{{ end }}
 {{ end }}
 
 {{ define "navbar" }}
@@ -45,7 +48,7 @@
         {{ else }}
         <div style="margin-bottom: 80px;"></div>
         {{ end }}
-        
+
         <div class="title">
           <h1>{{ .Page.Title }}</h1>
         </div>