shithub: hugo

Download patch

ref: 8947c3fa0beec021e14b3f8040857335e1ecd473
parent: d7798906d8e152a5d33f76ed0362628da8dd2c35
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Mon Mar 2 15:06:58 EST 2020

Fix ref/relref short lookup for pages in sub-folder

Fixes #6952

--- a/hugolib/pagecollections.go
+++ b/hugolib/pagecollections.go
@@ -305,7 +305,7 @@
 	}
 
 	// Ref/relref supports this potentially ambigous lookup.
-	return getByName(name)
+	return getByName(path.Base(name))
 
 }
 
--- a/hugolib/site_test.go
+++ b/hugolib/site_test.go
@@ -1030,11 +1030,13 @@
 }
 
 // https://github.com/gohugoio/hugo/issues/6952
-func TestRefBundle(t *testing.T) {
+func TestRefIssues(t *testing.T) {
 	b := newTestSitesBuilder(t)
 	b.WithContent(
 		"post/b1/index.md", "---\ntitle: pb1\n---\nRef: {{< ref \"b2\" >}}",
 		"post/b2/index.md", "---\ntitle: pb2\n---\n",
+		"post/nested-a/content-a.md", "---\ntitle: ca\n---\n{{< ref \"content-b\" >}}",
+		"post/nested-b/content-b.md", "---\ntitle: ca\n---\n",
 	)
 	b.WithTemplates("index.html", `Home`)
 	b.WithTemplates("_default/single.html", `Content: {{ .Content }}`)
@@ -1042,4 +1044,6 @@
 	b.Build(BuildCfg{})
 
 	b.AssertFileContent("public/post/b1/index.html", `Content: <p>Ref: http://example.com/post/b2/</p>`)
+	b.AssertFileContent("public/post/nested-a/content-a/index.html", `Content: http://example.com/post/nested-b/content-b/`)
+
 }