Skip to content

Commit e3bd40f

Browse files
Made absolute sitemap links
Signed-off-by: Ihor Aleksandrychiev <[email protected]>
1 parent b2292aa commit e3bd40f

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

generator/build/main.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,8 @@ if [ "$BRANCH" = "lts" ]; then
128128
sed -i '/^title = /s/ %branch%//' "$CONFIG_TOML"
129129
# Replace %branch% in searchBaseUrl with "lts"
130130
sed -i '/^searchBaseUrl = /s/%branch%/lts/' "$CONFIG_TOML"
131+
# Replace %branch% in sitemap baseUrl with "lts"
132+
sed -i 's|docs\.cfengine\.com/docs/%branch%|docs.cfengine.com/docs/lts|' "$CONFIG_TOML"
131133
# Set isLTS to true
132134
sed -i 's/isLTS = false/isLTS = true/' "$CONFIG_TOML"
133135
# Then replace remaining %branch% with LTS_VERSION

hugo/config.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ wrapperClass = 'hlc'
4242
[markup.goldmark.renderer]
4343
unsafe = true # Allow HTML in md files
4444

45+
[params.sitemap]
46+
baseUrl = "https://docs.cfengine.com/docs/%branch%"
47+
4548
[params.theme.colors]
4649
primary = "#15357f" # home page h1
4750
secondary = "#f5821f"

hugo/layouts/sitemap.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{{ printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
2+
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
3+
xmlns:xhtml="http://www.w3.org/1999/xhtml">
4+
{{ range .Data.Pages }}
5+
{{- if .Permalink -}}
6+
<url>
7+
<loc>{{ .Site.Params.Sitemap.BaseUrl }}{{ .Permalink }}</loc>{{ if not .Lastmod.IsZero }}
8+
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
9+
<changefreq>{{ . }}</changefreq>{{ end }}{{ if ge .Sitemap.Priority 0.0 }}
10+
<priority>{{ .Sitemap.Priority }}</priority>{{ end }}{{ if .IsTranslated }}{{ range .Translations }}
11+
<xhtml:link
12+
rel="alternate"
13+
hreflang="{{ .Language.LanguageCode }}"
14+
href="{{ .Permalink }}"
15+
/>{{ end }}
16+
<xhtml:link
17+
rel="alternate"
18+
hreflang="{{ .Language.LanguageCode }}"
19+
href="{{ .Permalink }}"
20+
/>{{ end }}
21+
</url>
22+
{{- end -}}
23+
{{ end }}
24+
</urlset>

0 commit comments

Comments
 (0)