Skip to content

Commit

Permalink
Merge pull request #1361 from camunda/pepopowitz/product-hub-232/7.18…
Browse files Browse the repository at this point in the history
…-versionful-canonicals

feat: update theme to use versioned canonicals
  • Loading branch information
pepopowitz committed Dec 2, 2022
2 parents bc41b29 + fa75284 commit 4e1d92c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
6 changes: 4 additions & 2 deletions themes/camunda/layouts/_default/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{{/* This template is overridden to emit permalinks that (1) are absolute, and (2) do not include a version. This allows us to submit the sitemap to crawlers with true canonical URLs. */}}
{{/* This template is overridden to emit permalinks that (1) are absolute, and (2) specify the most recent version. This allows us to submit the sitemap to crawlers with true canonical URLs. */}}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{ range .Data.Pages }}
<url>
{{- $permalink := .Permalink }}
{{- if ($.Site.Params.section.versions) }}
{{- $permalink = $permalink | replaceRE `(\/manual\/)([^\/]*\/)(.*)` `$1$3` }}
{{- $latestVersion := (index $.Site.Params.section.versions 1) }}
{{- $replacementPattern := print "${1}" $latestVersion "/${3}" }}
{{- $permalink = $permalink | replaceRE `(\/manual\/)([^\/]*\/)(.*)` $replacementPattern }}
{{- end }}
<loc>{{ $.Site.Params.canonicalBasePath }}{{ $permalink }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
Expand Down
8 changes: 7 additions & 1 deletion themes/camunda/layouts/partials/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@
{{ $styles := resources.Get "css/docs.css" | fingerprint }}

<link rel="stylesheet" href="{{ $styles.Permalink }}" integrity="{{ $styles.Data.Integrity }}">
<link rel="canonical" href="{{ $.Site.Params.canonicalBasePath }}{{ .Permalink | replaceRE `(\/manual\/)([^\/]*\/)(.*)` `$1$3` }}" />
{{- $permalink := .Permalink }}
{{- if ($.Site.Params.section.versions) }}
{{- $latestVersion := (index $.Site.Params.section.versions 1) }}
{{- $replacementPattern := print "${1}" $latestVersion "/${3}" }}
{{- $permalink = $permalink | replaceRE `(\/manual\/)([^\/]*\/)(.*)` $replacementPattern }}
{{- end }}
<link rel="canonical" href="{{ $.Site.Params.canonicalBasePath }}{{ $permalink }}" />
</head>
<body class="{{ .Params.bodyclass }}">

Expand Down

0 comments on commit 4e1d92c

Please sign in to comment.