@@ -267,8 +267,9 @@ tags: {{ range $term, $taxonomy := .Site.Taxonomies.tags }}{{ $term }}: {{ range
267267 }
268268}
269269
270- const filesVariationsSitesMatrix = `
270+ const filesVariationsSitesMatrixBase = `
271271-- hugo.toml --
272+ baseURL = "https://example.org/"
272273disableKinds = ["rss", "sitemap", "section"]
273274defaultContentLanguage = "en"
274275defaultContentLanguageInSubDir = true
@@ -313,6 +314,8 @@ target = 'content'
313314title: "English Home"
314315tags: ["tag1"]
315316---
317+
318+ Ref home: {{< ref "/" >}}|
316319-- content/en/p1.md --
317320---
318321title: "English p1"
@@ -322,6 +325,11 @@ title: "English p1"
322325title: "Nynorsk Heim"
323326tags: ["tag2"]
324327---
328+
329+ Ref home: {{< ref "/" >}}|
330+ `
331+
332+ const filesVariationsSitesMatrix = filesVariationsSitesMatrixBase + `
325333-- layouts/all.html --
326334title: {{ .Title }}|
327335tags: {{ range $term, $taxonomy := .Site.Taxonomies.tags }}{{ $term }}: {{ range $taxonomy.Pages }}{{ .Title }}: {{ .RelPermalink}}|{{ end }}{{ end }}$
@@ -373,6 +381,31 @@ sites:
373381 b .AssertFileContent ("public/guest/v1.4.0/en/p2/index.html" , "title: EN p2|" )
374382}
375383
384+ func TestGetPageAndRef (t * testing.T ) {
385+ t .Parallel ()
386+
387+ files := filesVariationsSitesMatrixBase + `
388+ -- layouts/all.html --
389+ Title: {{ .Title }}|
390+ Home: {{ with .Site.GetPage "/" }}{{ with .Site }}Language: {{ .Language.Name }}|Version: {{ .Version.Name }}|Role: {{ .Role.Name }}{{ end }}|{{ end }}$
391+ Content: {{ .Content }}$
392+ `
393+
394+ b := hugolib .Test (t , files )
395+ b .AssertFileContent (
396+ "public/guest/v2.0.0/en/index.html" , "Home: Language: en|Version: v2.0.0|Role: guest|$" ,
397+ "Ref home: https://example.org/guest/v2.0.0/en/|" ,
398+ )
399+ b .AssertFileContent (
400+ "public/member/v1.4.0/nn/index.html" , "Home: Language: nn|Version: v1.4.0|Role: member|$" ,
401+ )
402+
403+ b .AssertFileContent (
404+ "public/guest/v1.2.3/nn/index.html" , "Home: Language: nn|Version: v1.2.3|Role: guest|$" ,
405+ "Ref home: https://example.org/guest/v1.2.3/nn/|" ,
406+ )
407+ }
408+
376409func TestFrontMatterSitesMatrixShouldBeMergedWithMount (t * testing.T ) {
377410 t .Parallel ()
378411
0 commit comments