Backtestshugorun-20261024-162305#14625

Issue #14625 Merged fix PR #15384 Run 24 Oct 2026 · run-20261024-162305 gohugoio/hugo

Make default baseUrl https://example.org/

Better

Our patch was judged better than the merged fix.

In this judgment, Patch A = our agent, Patch B = the merged fix.

Both patches make an unconfigured site build with https://example.org/ and pass all independent tests, so the difference is in approach, tests, and scope. Patch A sets the default where Hugo keeps every other default, in newDefaultConfig, via a named DefaultBaseURL constant. That makes the value visible through normal config plumbing (A's testscript checks `hugo config` prints it), lets an explicit empty value still be distinguishable, and matches the conventions of the surrounding code. Patch B instead patches the value in late, inside CompileConfig, which is a symptom-level fallback: it silently rewrites any empty baseURL at compile time, bypasses the default-config mechanism, and would not show up in places that inspect the default config before compilation. On tests, A adds a focused integration test covering no config file, config without baseURL, multilingual, and explicit override, plus a server fixURL test confirming `hugo server` still maps the new default to localhost, plus a CLI testscript, and updates the docs entry. B adds a smaller three-case test and no docs. On scope, B's diff is dominated by unrelated reformatting of AssertFileContent calls across several test files, which obscures the actual change and adds review noise; A's test edits are confined to updating expectations or pinning baseURL where needed. A is the better fix on root cause placement, test coverage, documentation, and scope discipline.

Four judges ruled on this ticket in parallel, and the verdict comes from counting their votes. Each saw the issue and the two patches, labelled A and B in random order (two of them saw ours as A), with issue links and version numbers removed. Where tests could check the fix, they also saw the results of tests a separate agent wrote for the issue, run on both patches. None was told which patch was ours. The reasoning above is one judge's, shown verbatim.

Solve

1h 52m

Wall-clock time in the container

Full test suite

No new failures

2,436 passed · 8 skipped · 2,503 total

Contamination audit

Clean

No sign the agent saw the real fix

Patch size

233vs 284 merged

Changed lines, ours vs merged

If I want to create a very basic site, the only reason I currently need to create a config file is to set the baseUrl.

So, having the baseURL default to https://example.org/ would be a slightly breaking change, but it would solve more issues than it introduces.

The two patches

Our patch+181 −52
commands/server_test.gonew file mode 100644index 000000000..d6d379e52@@ -0,0 +1,37 @@+// Copyright 2026 The Hugo Authors. All rights reserved.+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package commands++import (+	"testing"++	qt "github.com/frankban/quicktest"+	"github.com/gohugoio/hugo/config/allconfig"+)++func TestServerFixURLDefaultBaseURL(t *testing.T) {+	c := qt.New(t)++	s := &serverCommand{serverAppend: true}++	// No baseURL configured and no --baseURL flag: serve on localhost.+	u, err := s.fixURL(allconfig.DefaultBaseURL, "", 1313)+	c.Assert(err, qt.IsNil)+	c.Assert(u, qt.Equals, "http://localhost:1313/")++	// The --baseURL flag still takes precedence over the default.+	u, err = s.fixURL(allconfig.DefaultBaseURL, "https://example.com/docs/", 1313)+	c.Assert(err, qt.IsNil)+	c.Assert(u, qt.Equals, "https://example.com:1313/docs/")+}config/allconfig/allconfig.goindex a84545edb..bedd28d46 100644@@ -594,7 +594,7 @@ func (c *ConfigCompiled) SetServerInfo(baseURL, baseURLLiveReload urls.BaseURL, // RootConfig holds all the top-level configuration options in Hugo type RootConfig struct { 	// The base URL of the site.-	// Note that the default value is empty, but Hugo requires a valid URL (e.g. "https://example.com/") to work properly.+	// The default value is "https://example.org/". 	// <docsmeta>{"identifiers": ["URL"] }</docsmeta> 	BaseURL string @@ -1011,6 +1011,7 @@ func (c Configs) GetByLang(lang string) config.AllProvider {  func newDefaultConfig() *Config { 	return &Config{+		BaseURL:              DefaultBaseURL, 		Taxonomies:           map[string]string{"tag": "tags", "category": "categories"}, 		Sitemap:              config.SitemapConfig{Priority: -1, Filename: "sitemap.xml"}, 		Environment:          hugo.EnvironmentProduction,@@ -1038,6 +1039,9 @@ func newDefaultConfig() *Config { 	} } +// DefaultBaseURL is the baseURL used when none is configured.+const DefaultBaseURL = "https://example.org/"+ // fromLoadConfigResult creates a new Config from res. func fromLoadConfigResult(fs afero.Fs, logger loggers.Logger, res config.LoadConfigResult) (*Configs, error) { 	if !res.Cfg.IsSet("languages") {config/allconfig/allconfig_integration_test.goindex e6e213b2b..ce1447ead 100644@@ -421,3 +421,69 @@ func TestLegacyEmbeddedRenderHookEnablement(t *testing.T) { 	b, _ = hugolib.TestE(t, f) 	b.AssertLogContains("ERROR deprecated") }++func TestDefaultBaseURL(t *testing.T) {+	t.Parallel()++	layouts := `+-- layouts/home.html --+BaseURL: {{ site.BaseURL }}|Permalink: {{ .Permalink }}|RelPermalink: {{ .RelPermalink }}|+-- layouts/single.html --+Permalink: {{ .Permalink }}|+-- content/p1.md --+---+title: "p1"+---+`++	t.Run("No config file", func(t *testing.T) {+		t.Parallel()+		b := hugolib.Test(t, layouts)+		b.Assert(b.H.Configs.Base.BaseURL, qt.Equals, allconfig.DefaultBaseURL)+		b.AssertFileContent("public/index.html", "BaseURL: https://example.org/|Permalink: https://example.org/|RelPermalink: /|")+		b.AssertFileContent("public/p1/index.html", "Permalink: https://example.org/p1/|")+	})++	t.Run("Config without baseURL", func(t *testing.T) {+		t.Parallel()+		files := `+-- hugo.toml --+title = "My Site"+` + layouts+		b := hugolib.Test(t, files)+		b.AssertFileContent("public/index.html", "BaseURL: https://example.org/|Permalink: https://example.org/|")+		b.AssertFileContent("public/p1/index.html", "Permalink: https://example.org/p1/|")+	})++	t.Run("Multilingual without baseURL", func(t *testing.T) {+		t.Parallel()+		files := `+-- hugo.toml --+defaultContentLanguage = "en"+[languages.en]+weight = 1+title = "English"+[languages.sv]+weight = 2+title = "Svenska"+-- content/p1.sv.md --+---+title: "p1 sv"+---+` + layouts+		b := hugolib.Test(t, files)+		b.AssertFileContent("public/index.html", "BaseURL: https://example.org/|Permalink: https://example.org/|")+		b.AssertFileContent("public/sv/index.html", "BaseURL: https://example.org/|Permalink: https://example.org/sv/|")+		b.AssertFileContent("public/sv/p1/index.html", "Permalink: https://example.org/sv/p1/|")+	})++	t.Run("Explicit baseURL wins", func(t *testing.T) {+		t.Parallel()+		files := `+-- hugo.toml --+baseURL = "https://example.com/docs/"+` + layouts+		b := hugolib.Test(t, files)+		b.AssertFileContent("public/index.html", "BaseURL: https://example.com/docs/|Permalink: https://example.com/docs/|RelPermalink: /docs/|")+	})+}docs/content/en/configuration/all.mdindex b8967eb87..6102c25f7 100644@@ -23,7 +23,7 @@ A general setting is a single value, such as [`baseURL`](#baseurl) or [`title`]( : (`string`) The designated directory for [global resources](g). Default is `assets`. {{% module-mounts-note %}}  `baseURL`-: (`string`) The absolute URL of your published site including the protocol, host, path, and a trailing slash.+: (`string`) The absolute URL of your published site including the protocol, host, path, and a trailing slash. Default is `https://example.org/`.  `build` : See [configure build][].hugolib/alias_test.goindex e9bfe8e6c..763e1f50d 100644@@ -36,8 +36,9 @@ func TestAlias(t *testing.T) { 		{"/index.html", "http://example.com", "/", map[string]any{"baseURL": "http://example.com"}}, 		{"/index.html", "http://example.com/some/path", "/", map[string]any{"baseURL": "http://example.com/some/path"}}, 		{"/index.html", "http://example.com", "/", map[string]any{"baseURL": "http://example.com", "canonifyURLs": true}},-		{"/index.html", "../..", "/", map[string]any{"relativeURLs": true}},-		{".html", "", ".html", map[string]any{"uglyURLs": true}},+		{"/index.html", "../..", "/", map[string]any{"baseURL": "/", "relativeURLs": true}},+		{".html", "https://example.org", ".html", map[string]any{"uglyURLs": true}},+		{".html", "", ".html", map[string]any{"baseURL": "/", "uglyURLs": true}}, 	}  	for _, test := range tests {@@ -726,10 +727,10 @@ Output format: foo|Title: {{ .Title }} 	b.AssertFileContent("public/de/foo.html", `Output format: foo|Title: home de`) 	b.AssertFileContent("public/index.html", ` <head>-  <title>/en/</title>-  <link rel="canonical" href="/en/">+  <title>https://example.org/en/</title>+  <link rel="canonical" href="https://example.org/en/">   <meta charset="utf-8">-  <meta http-equiv="refresh" content="0; url=/en/">+  <meta http-equiv="refresh" content="0; url=https://example.org/en/"> </head> 	`) @@ -743,10 +744,10 @@ Output format: foo|Title: {{ .Title }} 	b.AssertFileContent("public/de/foo.html", `Output format: foo|Title: home de`) 	b.AssertFileContent("public/index.html", ` <head>-  <title>/en/</title>-  <link rel="canonical" href="/en/">+  <title>https://example.org/en/</title>+  <link rel="canonical" href="https://example.org/en/">   <meta charset="utf-8">-  <meta http-equiv="refresh" content="0; url=/en/">+  <meta http-equiv="refresh" content="0; url=https://example.org/en/"> </head> 	`) }@@ -822,46 +823,46 @@ aliases: [a, b.foo, c.html, d.htm, e.foo.html, f.foo.htm]  	b := Test(t, f) -	b.AssertFileContent("public/s1/a/index.html", "url=/s1/p1/")-	b.AssertFileContent("public/s1/b.foo/index.html", "url=/s1/p1/")-	b.AssertFileContent("public/s1/c.html", "url=/s1/p1/")-	b.AssertFileContent("public/s1/d.htm", "url=/s1/p1/")-	b.AssertFileContent("public/s1/e.foo.html", "url=/s1/p1/")-	b.AssertFileContent("public/s1/f.foo.htm", "url=/s1/p1/")+	b.AssertFileContent("public/s1/a/index.html", "url=https://example.org/s1/p1/")+	b.AssertFileContent("public/s1/b.foo/index.html", "url=https://example.org/s1/p1/")+	b.AssertFileContent("public/s1/c.html", "url=https://example.org/s1/p1/")+	b.AssertFileContent("public/s1/d.htm", "url=https://example.org/s1/p1/")+	b.AssertFileContent("public/s1/e.foo.html", "url=https://example.org/s1/p1/")+	b.AssertFileContent("public/s1/f.foo.htm", "url=https://example.org/s1/p1/")  	r = strings.NewReplacer("UGLYURLS", "false", "SUFFIXES", "['htm', 'html']") 	f = r.Replace(files)  	b = Test(t, f) -	b.AssertFileContent("public/s1/a/index.htm", "url=/s1/p1/")-	b.AssertFileContent("public/s1/b.foo/index.htm", "url=/s1/p1/")-	b.AssertFileContent("public/s1/c.html", "url=/s1/p1/")-	b.AssertFileContent("public/s1/d.htm", "url=/s1/p1/")-	b.AssertFileContent("public/s1/e.foo.html", "url=/s1/p1/")-	b.AssertFileContent("public/s1/f.foo.htm", "url=/s1/p1/")+	b.AssertFileContent("public/s1/a/index.htm", "url=https://example.org/s1/p1/")+	b.AssertFileContent("public/s1/b.foo/index.htm", "url=https://example.org/s1/p1/")+	b.AssertFileContent("public/s1/c.html", "url=https://example.org/s1/p1/")+	b.AssertFileContent("public/s1/d.htm", "url=https://example.org/s1/p1/")+	b.AssertFileContent("public/s1/e.foo.html", "url=https://example.org/s1/p1/")+	b.AssertFileContent("public/s1/f.foo.htm", "url=https://example.org/s1/p1/")  	r = strings.NewReplacer("UGLYURLS", "true", "SUFFIXES", "['html', 'htm']") 	f = r.Replace(files)  	b = Test(t, f) -	b.AssertFileContent("public/s1/a.html", "url=/s1/p1.html")-	b.AssertFileContent("public/s1/b.foo.html", "url=/s1/p1.html")-	b.AssertFileContent("public/s1/c.html", "url=/s1/p1.html")-	b.AssertFileContent("public/s1/d.htm", "url=/s1/p1.html")-	b.AssertFileContent("public/s1/e.foo.html", "url=/s1/p1.html")-	b.AssertFileContent("public/s1/f.foo.htm", "url=/s1/p1.html")+	b.AssertFileContent("public/s1/a.html", "url=https://example.org/s1/p1.html")+	b.AssertFileContent("public/s1/b.foo.html", "url=https://example.org/s1/p1.html")+	b.AssertFileContent("public/s1/c.html", "url=https://example.org/s1/p1.html")+	b.AssertFileContent("public/s1/d.htm", "url=https://example.org/s1/p1.html")+	b.AssertFileContent("public/s1/e.foo.html", "url=https://example.org/s1/p1.html")+	b.AssertFileContent("public/s1/f.foo.htm", "url=https://example.org/s1/p1.html")  	r = strings.NewReplacer("UGLYURLS", "true", "SUFFIXES", "['htm', 'html']") 	f = r.Replace(files)  	b = Test(t, f) -	b.AssertFileContent("public/s1/a.htm", "url=/s1/p1.htm")-	b.AssertFileContent("public/s1/b.foo.htm", "url=/s1/p1.htm")-	b.AssertFileContent("public/s1/c.html", "url=/s1/p1.htm")-	b.AssertFileContent("public/s1/d.htm", "url=/s1/p1.htm")-	b.AssertFileContent("public/s1/e.foo.html", "url=/s1/p1.htm")-	b.AssertFileContent("public/s1/f.foo.htm", "url=/s1/p1.htm")+	b.AssertFileContent("public/s1/a.htm", "url=https://example.org/s1/p1.htm")+	b.AssertFileContent("public/s1/b.foo.htm", "url=https://example.org/s1/p1.htm")+	b.AssertFileContent("public/s1/c.html", "url=https://example.org/s1/p1.htm")+	b.AssertFileContent("public/s1/d.htm", "url=https://example.org/s1/p1.htm")+	b.AssertFileContent("public/s1/e.foo.html", "url=https://example.org/s1/p1.htm")+	b.AssertFileContent("public/s1/f.foo.htm", "url=https://example.org/s1/p1.htm") }testscripts/commands/config__default_baseurl.txtnew file mode 100644index 000000000..bce4fa50a@@ -0,0 +1,21 @@+# Test that baseURL defaults to https://example.org/ when not configured.++hugo config+stdout 'baseurl = .https://example.org/'++hugo+grep 'Permalink: https://example.org/p1/' public/p1/index.html+grep '<loc>https://example.org/p1/</loc>' public/sitemap.xml++# Test files+-- hugo.toml --+title="My New Hugo Project"+disableKinds = ['rss','section','taxonomy','term']+-- layouts/home.html --+Home.+-- layouts/single.html --+Permalink: {{ .Permalink }}|+-- content/p1.md --+---+title: p1+---tpl/tplimpl/embedded_templates_integration_test.goindex 5790216cc..939ce0822 100644@@ -211,7 +211,7 @@ title: p0 	b := hugolib.Test(t, files)  	b.AssertFileContent("public/s1/p1/index.html", `-		<meta property="og:url" content="/s1/p1/">+		<meta property="og:url" content="https://example.org/s1/p1/"> 		<meta property="og:site_name" content="My Site"> 		<meta property="og:title" content="p1"> 		<meta property="og:description" content="a b and c can’t.">@@ -222,16 +222,16 @@ title: p0 		<meta property="article:modified_time" content="2024-04-24T11:00:00-07:00"> 		<meta property="article:tag" content="t1"> 		<meta property="article:tag" content="t2">-		<meta property="og:image" content="/a.jpg">-		<meta property="og:image" content="/b.jpg">-		<meta property="og:audio" content="/c.mp3">-		<meta property="og:audio" content="/d.mp3">-		<meta property="og:video" content="/e.mp4">-		<meta property="og:video" content="/f.mp4">-		<meta property="og:see_also" content="/s1/p2/">-		<meta property="og:see_also" content="/s1/p3/">-		<meta property="og:see_also" content="/s1/p4/">-		<meta property="og:see_also" content="/s1/p5/">+		<meta property="og:image" content="https://example.org/a.jpg">+		<meta property="og:image" content="https://example.org/b.jpg">+		<meta property="og:audio" content="https://example.org/c.mp3">+		<meta property="og:audio" content="https://example.org/d.mp3">+		<meta property="og:video" content="https://example.org/e.mp4">+		<meta property="og:video" content="https://example.org/f.mp4">+		<meta property="og:see_also" content="https://example.org/s1/p2/">+		<meta property="og:see_also" content="https://example.org/s1/p3/">+		<meta property="og:see_also" content="https://example.org/s1/p4/">+		<meta property="og:see_also" content="https://example.org/s1/p5/"> 		<meta property="fb:admins" content="foo"> 		`, 	)@@ -269,7 +269,7 @@ title: p0  	// Term page 	b.AssertFileContent("public/series/series-1/index.html",-		`<meta property="og:url" content="/series/series-1/">`,+		`<meta property="og:url" content="https://example.org/series/series-1/">`, 		`<meta property="og:title" content="series-1">`, 		`<meta property="og:type" content="website">`, 	)@@ -468,8 +468,8 @@ keywords: [k1,k2] 		<meta itemprop="datePublished" content="2024-04-24T08:00:00-07:00"> 		<meta itemprop="dateModified" content="2024-04-24T11:00:00-07:00"> 		<meta itemprop="wordCount" content="5">-		<meta itemprop="image" content="/a.jpg">-		<meta itemprop="image" content="/b.jpg">+		<meta itemprop="image" content="https://example.org/a.jpg">+		<meta itemprop="image" content="https://example.org/b.jpg"> 		<meta itemprop="keywords" content="t1,t2">   		`, 	)@@ -588,7 +588,7 @@ title: ''  	b.AssertFileContent("public/s1/p1/index.html", ` 		<meta name="twitter:card" content="summary_large_image">-		<meta name="twitter:image" content="/a.jpg">+		<meta name="twitter:image" content="https://example.org/a.jpg"> 		<meta name="twitter:title" content="p1"> 		<meta name="twitter:description" content="a b and c can’t."> 		<meta name="twitter:site" content="@foo">tpl/tplimpl/tplimpl_integration_test.goindex 647500207..04bd581c6 100644@@ -196,21 +196,21 @@ title: p2 	files_b := strings.ReplaceAll(files, "disable = true", "disable = false") 	b = hugolib.Test(t, files_b) 	b.AssertFileContentExact("public/sitemap.xml",-		"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n  xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n  <url>\n    <loc>/p1/</loc>\n  </url><url>\n    <loc>/p2/</loc>\n  </url>\n</urlset>\n",+		"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n  xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n  <url>\n    <loc>https://example.org/p1/</loc>\n  </url><url>\n    <loc>https://example.org/p2/</loc>\n  </url>\n</urlset>\n", 	)  	// Test C: Exclude all pages via project config, but include p1 via front matter. 	files_c := strings.ReplaceAll(files, "p1_disable: foo", "disable: false") 	b = hugolib.Test(t, files_c) 	b.AssertFileContentExact("public/sitemap.xml",-		"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n  xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n  <url>\n    <loc>/p1/</loc>\n  </url>\n</urlset>\n",+		"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n  xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n  <url>\n    <loc>https://example.org/p1/</loc>\n  </url>\n</urlset>\n", 	)  	// Test D:  Include all pages via project config, but exclude p1 via front matter. 	files_d := strings.ReplaceAll(files_b, "p1_disable: foo", "disable: true") 	b = hugolib.Test(t, files_d) 	b.AssertFileContentExact("public/sitemap.xml",-		"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n  xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n  <url>\n    <loc>/p2/</loc>\n  </url>\n</urlset>\n",+		"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n  xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n  <url>\n    <loc>https://example.org/p2/</loc>\n  </url>\n</urlset>\n", 	) }  
Merged fix · PR #15384+196 −88
config/allconfig/allconfig.goindex a84545edb..0cb1f3a6b 100644@@ -357,6 +357,10 @@ func (c *Config) CompileConfig(logger loggers.Logger) error { 		ignoredLogIDs[err] = true 	} +	if c.BaseURL == "" {+		c.BaseURL = "https://example.org/"+	}+ 	baseURL, err := urls.NewBaseURLFromString(c.BaseURL) 	if err != nil { 		return err@@ -594,7 +598,7 @@ func (c *ConfigCompiled) SetServerInfo(baseURL, baseURLLiveReload urls.BaseURL, // RootConfig holds all the top-level configuration options in Hugo type RootConfig struct { 	// The base URL of the site.-	// Note that the default value is empty, but Hugo requires a valid URL (e.g. "https://example.com/") to work properly.+	// It defaults to https://example.org/ 	// <docsmeta>{"identifiers": ["URL"] }</docsmeta> 	BaseURL string hugolib/alias_test.goindex e9bfe8e6c..e7072689e 100644@@ -36,8 +36,8 @@ func TestAlias(t *testing.T) { 		{"/index.html", "http://example.com", "/", map[string]any{"baseURL": "http://example.com"}}, 		{"/index.html", "http://example.com/some/path", "/", map[string]any{"baseURL": "http://example.com/some/path"}}, 		{"/index.html", "http://example.com", "/", map[string]any{"baseURL": "http://example.com", "canonifyURLs": true}},-		{"/index.html", "../..", "/", map[string]any{"relativeURLs": true}},-		{".html", "", ".html", map[string]any{"uglyURLs": true}},+		{"/index.html", "../..", "/", map[string]any{"relativeURLs": true, "baseURL": "/"}},+		{".html", "", ".html", map[string]any{"uglyURLs": true, "baseURL": "/"}}, 	}  	for _, test := range tests {@@ -273,22 +273,26 @@ aliases: [/p2-alias] 	b := Test(t, f)  	// output format: html-	b.AssertFileContent("public/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/foo/s1-alias/index.html", 		`<title>https://example.org/foo/s1/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/foo/s1/">`, 	)-	b.AssertFileContent("public/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/foo/s1/p1-alias/index.html", 		`<title>https://example.org/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/s2-alias/index.html",+	b.AssertFileContent(+		"public/s2-alias/index.html", 		`<title>https://example.org/foo/s2/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/foo/s2/">`, 	)-	b.AssertFileContent("public/p2-alias/index.html",+	b.AssertFileContent(+		"public/p2-alias/index.html", 		`<title>https://example.org/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/foo/s2/p2/">`,@@ -347,44 +351,52 @@ aliases: [/p2-alias] 	b = Test(t, f)  	// output format: html-	b.AssertFileContent("public/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/foo/s1-alias/index.html", 		`<title>https://example.org/foo/s1/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/foo/s1/">`, 	)-	b.AssertFileContent("public/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/foo/s1/p1-alias/index.html", 		`<title>https://example.org/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/s2-alias/index.html",+	b.AssertFileContent(+		"public/s2-alias/index.html", 		`<title>https://example.org/foo/s2/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/foo/s2/">`, 	)-	b.AssertFileContent("public/p2-alias/index.html",+	b.AssertFileContent(+		"public/p2-alias/index.html", 		`<title>https://example.org/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/foo/s2/p2/">`, 	)  	// output format: print-	b.AssertFileContent("public/print/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/print/foo/s1-alias/index.html", 		`<title>https://example.org/print/foo/s1/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/print/foo/s1/">`, 	)-	b.AssertFileContent("public/print/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/print/foo/s1/p1-alias/index.html", 		`<title>https://example.org/print/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/print/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/print/s2-alias/index.html",+	b.AssertFileContent(+		"public/print/s2-alias/index.html", 		`<title>https://example.org/print/foo/s2/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/print/foo/s2/">`, 	)-	b.AssertFileContent("public/print/p2-alias/index.html",+	b.AssertFileContent(+		"public/print/p2-alias/index.html", 		`<title>https://example.org/print/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://example.org/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/print/foo/s2/p2/">`,@@ -473,88 +485,104 @@ aliases: [/p2-alias] 	b := Test(t, files)  	// language: de, output format: html-	b.AssertFileContent("public/guest/v1.0.0/de/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/de/foo/s1-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/de/foo/s1/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/de/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/de/foo/s1/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/de/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/de/foo/s1/p1-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/de/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/de/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/de/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/de/s2-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/de/s2-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/de/foo/s2/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/de/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/de/foo/s2/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/de/p2-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/de/p2-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/de/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/de/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/de/foo/s2/p2/">`, 	)  	// language: de, output format: print-	b.AssertFileContent("public/guest/v1.0.0/de/print/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/de/print/foo/s1-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/de/print/foo/s1/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/de/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/de/print/foo/s1/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/de/print/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/de/print/foo/s1/p1-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/de/print/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/de/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/de/print/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/de/print/s2-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/de/print/s2-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/de/print/foo/s2/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/de/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/de/print/foo/s2/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/de/print/p2-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/de/print/p2-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/de/print/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/de/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/de/print/foo/s2/p2/">`, 	)  	// language: en, output format: html-	b.AssertFileContent("public/guest/v1.0.0/en/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/en/foo/s1-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/en/foo/s1/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/en/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/en/foo/s1/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/en/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/en/foo/s1/p1-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/en/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/en/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/en/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/en/s2-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/en/s2-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/en/foo/s2/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/en/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/en/foo/s2/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/en/p2-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/en/p2-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/en/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/en/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/en/foo/s2/p2/">`, 	)  	// language: en, output format: print-	b.AssertFileContent("public/guest/v1.0.0/en/print/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/en/print/foo/s1-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/en/print/foo/s1/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/en/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/en/print/foo/s1/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/en/print/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/en/print/foo/s1/p1-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/en/print/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/en/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/en/print/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/en/print/s2-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/en/print/s2-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/en/print/foo/s2/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/en/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/en/print/foo/s2/">`, 	)-	b.AssertFileContent("public/guest/v1.0.0/en/print/p2-alias/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/en/print/p2-alias/index.html", 		`<title>https://example.org/guest/v1.0.0/en/print/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://example.org/guest/v1.0.0/en/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://example.org/guest/v1.0.0/en/print/foo/s2/p2/">`,@@ -568,88 +596,104 @@ aliases: [/p2-alias] 	b = Test(t, files)  	// language: de, output format: html-	b.AssertFileContent("public/de/guest/v1.0.0/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/de/guest/v1.0.0/foo/s1-alias/index.html", 		`<title>https://de.example.org/guest/v1.0.0/foo/s1/</title>`, 		`<link rel="canonical" href="https://de.example.org/guest/v1.0.0/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://de.example.org/guest/v1.0.0/foo/s1/">`, 	)-	b.AssertFileContent("public/de/guest/v1.0.0/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/de/guest/v1.0.0/foo/s1/p1-alias/index.html", 		`<title>https://de.example.org/guest/v1.0.0/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://de.example.org/guest/v1.0.0/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://de.example.org/guest/v1.0.0/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/de/guest/v1.0.0/s2-alias/index.html",+	b.AssertFileContent(+		"public/de/guest/v1.0.0/s2-alias/index.html", 		`<title>https://de.example.org/guest/v1.0.0/foo/s2/</title>`, 		`<link rel="canonical" href="https://de.example.org/guest/v1.0.0/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://de.example.org/guest/v1.0.0/foo/s2/">`, 	)-	b.AssertFileContent("public/de/guest/v1.0.0/p2-alias/index.html",+	b.AssertFileContent(+		"public/de/guest/v1.0.0/p2-alias/index.html", 		`<title>https://de.example.org/guest/v1.0.0/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://de.example.org/guest/v1.0.0/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://de.example.org/guest/v1.0.0/foo/s2/p2/">`, 	)  	// language: de, output format: print-	b.AssertFileContent("public/de/guest/v1.0.0/print/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/de/guest/v1.0.0/print/foo/s1-alias/index.html", 		`<title>https://de.example.org/guest/v1.0.0/print/foo/s1/</title>`, 		`<link rel="canonical" href="https://de.example.org/guest/v1.0.0/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://de.example.org/guest/v1.0.0/print/foo/s1/">`, 	)-	b.AssertFileContent("public/de/guest/v1.0.0/print/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/de/guest/v1.0.0/print/foo/s1/p1-alias/index.html", 		`<title>https://de.example.org/guest/v1.0.0/print/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://de.example.org/guest/v1.0.0/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://de.example.org/guest/v1.0.0/print/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/de/guest/v1.0.0/print/s2-alias/index.html",+	b.AssertFileContent(+		"public/de/guest/v1.0.0/print/s2-alias/index.html", 		`<title>https://de.example.org/guest/v1.0.0/print/foo/s2/</title>`, 		`<link rel="canonical" href="https://de.example.org/guest/v1.0.0/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://de.example.org/guest/v1.0.0/print/foo/s2/">`, 	)-	b.AssertFileContent("public/de/guest/v1.0.0/print/p2-alias/index.html",+	b.AssertFileContent(+		"public/de/guest/v1.0.0/print/p2-alias/index.html", 		`<title>https://de.example.org/guest/v1.0.0/print/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://de.example.org/guest/v1.0.0/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://de.example.org/guest/v1.0.0/print/foo/s2/p2/">`, 	)  	// language: en, output format: html-	b.AssertFileContent("public/en/guest/v1.0.0/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/en/guest/v1.0.0/foo/s1-alias/index.html", 		`<title>https://en.example.org/guest/v1.0.0/foo/s1/</title>`, 		`<link rel="canonical" href="https://en.example.org/guest/v1.0.0/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://en.example.org/guest/v1.0.0/foo/s1/">`, 	)-	b.AssertFileContent("public/en/guest/v1.0.0/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/en/guest/v1.0.0/foo/s1/p1-alias/index.html", 		`<title>https://en.example.org/guest/v1.0.0/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://en.example.org/guest/v1.0.0/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://en.example.org/guest/v1.0.0/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/en/guest/v1.0.0/s2-alias/index.html",+	b.AssertFileContent(+		"public/en/guest/v1.0.0/s2-alias/index.html", 		`<title>https://en.example.org/guest/v1.0.0/foo/s2/</title>`, 		`<link rel="canonical" href="https://en.example.org/guest/v1.0.0/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://en.example.org/guest/v1.0.0/foo/s2/">`, 	)-	b.AssertFileContent("public/en/guest/v1.0.0/p2-alias/index.html",+	b.AssertFileContent(+		"public/en/guest/v1.0.0/p2-alias/index.html", 		`<title>https://en.example.org/guest/v1.0.0/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://en.example.org/guest/v1.0.0/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://en.example.org/guest/v1.0.0/foo/s2/p2/">`, 	)  	// language: en, output format: print-	b.AssertFileContent("public/en/guest/v1.0.0/print/foo/s1-alias/index.html",+	b.AssertFileContent(+		"public/en/guest/v1.0.0/print/foo/s1-alias/index.html", 		`<title>https://en.example.org/guest/v1.0.0/print/foo/s1/</title>`, 		`<link rel="canonical" href="https://en.example.org/guest/v1.0.0/foo/s1/">`, 		`<meta http-equiv="refresh" content="0; url=https://en.example.org/guest/v1.0.0/print/foo/s1/">`, 	)-	b.AssertFileContent("public/en/guest/v1.0.0/print/foo/s1/p1-alias/index.html",+	b.AssertFileContent(+		"public/en/guest/v1.0.0/print/foo/s1/p1-alias/index.html", 		`<title>https://en.example.org/guest/v1.0.0/print/foo/s1/p1/</title>`, 		`<link rel="canonical" href="https://en.example.org/guest/v1.0.0/foo/s1/p1/">`, 		`<meta http-equiv="refresh" content="0; url=https://en.example.org/guest/v1.0.0/print/foo/s1/p1/">`, 	)-	b.AssertFileContent("public/en/guest/v1.0.0/print/s2-alias/index.html",+	b.AssertFileContent(+		"public/en/guest/v1.0.0/print/s2-alias/index.html", 		`<title>https://en.example.org/guest/v1.0.0/print/foo/s2/</title>`, 		`<link rel="canonical" href="https://en.example.org/guest/v1.0.0/foo/s2/">`, 		`<meta http-equiv="refresh" content="0; url=https://en.example.org/guest/v1.0.0/print/foo/s2/">`, 	)-	b.AssertFileContent("public/en/guest/v1.0.0/print/p2-alias/index.html",+	b.AssertFileContent(+		"public/en/guest/v1.0.0/print/p2-alias/index.html", 		`<title>https://en.example.org/guest/v1.0.0/print/foo/s2/p2/</title>`, 		`<link rel="canonical" href="https://en.example.org/guest/v1.0.0/foo/s2/p2/">`, 		`<meta http-equiv="refresh" content="0; url=https://en.example.org/guest/v1.0.0/print/foo/s2/p2/">`,@@ -679,7 +723,8 @@ Home. ` 	b := Test(t, files) -	b.AssertFileContent("public/guest/v1.0.0/en/index.html",+	b.AssertFileContent(+		"public/guest/v1.0.0/en/index.html", 		"/guest/v1.0.0/en/foo/p2            =>/guest/v1.0.0/en/foo/p1/|", 		"/guest/v1.0.0/en/p3                =>/guest/v1.0.0/en/foo/p1/|", 	)@@ -691,6 +736,7 @@ func TestOutputFormatIsHTMLWithMultilangAliases(t *testing.T) {  	files := ` -- hugo.toml --+baseURL = "/" defaultContentLanguageInSubdir = true disableKinds = ['page', 'section', 'rss', 'sitemap', 'taxonomy', 'term'] @@ -799,6 +845,7 @@ func TestAliasExplicitExtension(t *testing.T) { -- hugo.toml -- disableKinds = ['home','rss','section','sitemap','taxonomy','term'] uglyURLs = UGLYURLS+baseURL = "/"  [mediaTypes]   [mediaTypes.'text/html']hugolib/page_permalink_test.goindex c2fe8f089..d5ae69375 100644@@ -34,17 +34,17 @@ func TestPermalink(t *testing.T) { 		expectedAbs  string 		expectedRel  string 	}{-		{"x/y/z/boofar.md", "", "", "", false, false, "/x/y/z/boofar/", "/x/y/z/boofar/"},-		{"x/y/z/boofar.md", "", "", "", false, false, "/x/y/z/boofar/", "/x/y/z/boofar/"},+		{"x/y/z/boofar.md", "/", "", "", false, false, "/x/y/z/boofar/", "/x/y/z/boofar/"},+		{"x/y/z/boofar.md", "/", "", "", false, false, "/x/y/z/boofar/", "/x/y/z/boofar/"}, 		// Issue #1174 		{"x/y/z/boofar.md", "http://gopher.com/", "", "", false, true, "http://gopher.com/x/y/z/boofar/", "/x/y/z/boofar/"}, 		{"x/y/z/boofar.md", "http://gopher.com/", "", "", true, true, "http://gopher.com/x/y/z/boofar.html", "/x/y/z/boofar.html"},-		{"x/y/z/boofar.md", "", "boofar", "", false, false, "/x/y/z/boofar/", "/x/y/z/boofar/"},+		{"x/y/z/boofar.md", "/", "boofar", "", false, false, "/x/y/z/boofar/", "/x/y/z/boofar/"}, 		{"x/y/z/boofar.md", "http://barnew/", "", "", false, false, "http://barnew/x/y/z/boofar/", "/x/y/z/boofar/"}, 		{"x/y/z/boofar.md", "http://barnew/", "boofar", "", false, false, "http://barnew/x/y/z/boofar/", "/x/y/z/boofar/"},-		{"x/y/z/boofar.md", "", "", "", true, false, "/x/y/z/boofar.html", "/x/y/z/boofar.html"},-		{"x/y/z/boofar.md", "", "", "", true, false, "/x/y/z/boofar.html", "/x/y/z/boofar.html"},-		{"x/y/z/boofar.md", "", "boofar", "", true, false, "/x/y/z/boofar.html", "/x/y/z/boofar.html"},+		{"x/y/z/boofar.md", "/", "", "", true, false, "/x/y/z/boofar.html", "/x/y/z/boofar.html"},+		{"x/y/z/boofar.md", "/", "", "", true, false, "/x/y/z/boofar.html", "/x/y/z/boofar.html"},+		{"x/y/z/boofar.md", "/", "boofar", "", true, false, "/x/y/z/boofar.html", "/x/y/z/boofar.html"}, 		{"x/y/z/boofar.md", "http://barnew/", "", "", true, false, "http://barnew/x/y/z/boofar.html", "/x/y/z/boofar.html"}, 		{"x/y/z/boofar.md", "http://barnew/", "boofar", "", true, false, "http://barnew/x/y/z/boofar.html", "/x/y/z/boofar.html"}, 		{"x/y/z/boofar.md", "http://barnew/boo/", "booslug", "", true, false, "http://barnew/boo/x/y/z/booslug.html", "/boo/x/y/z/booslug.html"},@@ -56,9 +56,9 @@ func TestPermalink(t *testing.T) { 		{"x/y/z/boo-makeindex.md", "http://barnew/boo", "", "", true, true, "http://barnew/boo/x/y/z/boo-makeindex.html", "/x/y/z/boo-makeindex.html"},  		// test URL overrides-		{"x/y/z/boofar.md", "", "", "/z/y/q/", false, false, "/z/y/q/", "/z/y/q/"},+		{"x/y/z/boofar.md", "/", "", "/z/y/q/", false, false, "/z/y/q/", "/z/y/q/"}, 		// test URL override with expands-		{"x/y/z/boofar.md", "", "test", "/z/:slug/", false, false, "/z/test/", "/z/test/"},+		{"x/y/z/boofar.md", "/", "test", "/z/:slug/", false, false, "/z/test/", "/z/test/"}, 	}  	for i, test := range tests {hugolib/site_url_test.goindex 253969a34..b96dd3de2 100644@@ -14,6 +14,7 @@ package hugolib  import (+	"strings" 	"testing" ) @@ -33,3 +34,25 @@ SectionsEntries: {{ .SectionsEntries }} 	b.AssertFileContent("public/withfile/index.html", "SectionsEntries: [withfile]") 	b.AssertFileContent("public/withoutfile/index.html", "SectionsEntries: [withoutfile]") }++// See #14625.+func TestDefaultBaseURL(t *testing.T) {+	filesTemplate := `+-- hugo.toml --+CONFIG+-- content/_index.md --+-- layouts/list.html --+BaseURL: {{ .Site.BaseURL }}+`+	files := strings.ReplaceAll(filesTemplate, "CONFIG", `baseURL = "https://example.com/"`)+	b := Test(t, files)+	b.AssertFileContent("public/index.html", "BaseURL: https://example.com/")++	files = strings.ReplaceAll(filesTemplate, "CONFIG", "")+	b = Test(t, files)+	b.AssertFileContent("public/index.html", "BaseURL: https://example.org/")++	files = strings.ReplaceAll(filesTemplate, "CONFIG", `baseURL = "/"`)+	b = Test(t, files)+	b.AssertFileContent("public/index.html", "BaseURL: /")+}tpl/tplimpl/embedded_templates_integration_test.goindex 5790216cc..4fa17d71d 100644@@ -47,7 +47,8 @@ disqus_url = 'https://example.com/my-page/'  	b := hugolib.Test(t, files) -	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		`s.src = '//' + "foo" + '.disqus.com/embed.js';`, 		`this.page.identifier = 'my-identifier';`, 		`this.page.title = 'My Title';`,@@ -88,7 +89,8 @@ title: Home 	// Default respectDoNotTrack value 	f := strings.ReplaceAll(files, "DNT", "") 	b := hugolib.Test(t, f)-	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		`<script async src="https://www.googletagmanager.com/gtag/js?id=G-0123456789"></script>`, 		`if ( true )`, 	)@@ -96,7 +98,8 @@ title: Home 	// respectDoNotTrack = true 	f = strings.ReplaceAll(files, "DNT", "respectDoNotTrack = true") 	b = hugolib.Test(t, f)-	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		`<script async src="https://www.googletagmanager.com/gtag/js?id=G-0123456789"></script>`, 		`if ( true )`, 	)@@ -104,7 +107,8 @@ title: Home 	// respectDoNotTrack = false 	f = strings.ReplaceAll(files, "DNT", "respectDoNotTrack = false") 	b = hugolib.Test(t, f)-	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		`<script async src="https://www.googletagmanager.com/gtag/js?id=G-0123456789"></script>`, 		`if ( false )`, 	)@@ -133,6 +137,7 @@ func TestOpengraphTemplate(t *testing.T) {  	files := ` -- hugo.toml --+baseURL = "/" title = 'My Site' capitalizeListTitles = false disableKinds = ['section','rss','sitemap','taxonomy']@@ -210,7 +215,8 @@ title: p0  	b := hugolib.Test(t, files) -	b.AssertFileContent("public/s1/p1/index.html", `+	b.AssertFileContent(+		"public/s1/p1/index.html", ` 		<meta property="og:url" content="/s1/p1/"> 		<meta property="og:site_name" content="My Site"> 		<meta property="og:title" content="p1">@@ -237,38 +243,45 @@ title: p0 	)  	// Description from content excerpt-	b.AssertFileContent("public/s1/p2/index.html",+	b.AssertFileContent(+		"public/s1/p2/index.html", 		`<meta property="og:description" content="d e and f can’t.">`, 	)  	// Description from front matter summary-	b.AssertFileContent("public/s1/p3/index.html",+	b.AssertFileContent(+		"public/s1/p3/index.html", 		`<meta property="og:description" content="g h and i can’t.">`, 	)  	// The markdown is intentionally not rendered to HTML.-	b.AssertFileContent("public/s1/p4/index.html",+	b.AssertFileContent(+		"public/s1/p4/index.html", 		`<meta property="og:description" content="j k and **l** can&#39;t.">`, 	)  	// The markdown is intentionally not rendered to HTML.-	b.AssertFileContent("public/s1/p5/index.html",+	b.AssertFileContent(+		"public/s1/p5/index.html", 		`<meta property="og:description" content="m n and **o** can&#39;t.">`, 	)  	// og:locale from page front matter-	b.AssertFileContent("public/s1/p6/index.html",+	b.AssertFileContent(+		"public/s1/p6/index.html", 		`<meta property="og:locale" content="fr_FR">`, 	)  	// No article:section for root-level page-	b.AssertFileContent("public/p0/index.html",+	b.AssertFileContent(+		"public/p0/index.html", 		`<meta property="og:type" content="article">`, 		`! article:section`, 	)  	// Term page-	b.AssertFileContent("public/series/series-1/index.html",+	b.AssertFileContent(+		"public/series/series-1/index.html", 		`<meta property="og:url" content="/series/series-1/">`, 		`<meta property="og:title" content="series-1">`, 		`<meta property="og:type" content="website">`,@@ -280,13 +293,15 @@ title: p0 	// facebook_app_id takes precedence over facebook_admin 	f := strings.ReplaceAll(files, "facebook_admin = 'foo'", "facebook_app_id = 'bar'") 	b = hugolib.Test(t, f)-	b.AssertFileContent("public/s1/p1/index.html",+	b.AssertFileContent(+		"public/s1/p1/index.html", 		`<meta property="fb:app_id" content="bar">`, 		`! fb:admins`, 	)  	// Issue 14433-	b.AssertFileContent("public/index.html",+	b.AssertFileContent(+		"public/index.html", 		`<meta property="og:title" content="Home">`, 		`<meta property="og:locale" content="en_US">`, 		`<meta property="og:type" content="website">`,@@ -365,7 +380,8 @@ title: p10 	// Default format, last page: active First and Prev, disabled Next and Last 	f := strings.ReplaceAll(files, "PARTIAL", `{{ partial "pagination.html" . }}`) 	b := hugolib.Test(t, f)-	b.AssertFileContent("public/page/10/index.html",+	b.AssertFileContent(+		"public/page/10/index.html", 		`<a href="/" aria-label="First" class="page-link" role="button">`, 		`<a href="/page/9/" aria-label="Previous" class="page-link" role="button">`, 		`aria-disabled="true" aria-label="Next"`,@@ -375,7 +391,8 @@ title: p10 	// Terse format, last page: First and Prev shown, Next and Last hidden 	f = strings.ReplaceAll(files, "PARTIAL", `{{ partial "pagination.html" (dict "page" . "format" "terse") }}`) 	b = hugolib.Test(t, f)-	b.AssertFileContent("public/page/10/index.html",+	b.AssertFileContent(+		"public/page/10/index.html", 		`<a href="/" aria-label="First" class="page-link" role="button">`, 		`<a href="/page/9/" aria-label="Previous" class="page-link" role="button">`, 		`! aria-label="Next"`,@@ -412,6 +429,7 @@ func TestSchemaTemplate(t *testing.T) {  	files := ` -- hugo.toml --+baseURL = "/" capitalizeListTitles = false disableKinds = ['rss','sitemap'] [markup.goldmark.renderer]@@ -462,7 +480,8 @@ keywords: [k1,k2]  	b := hugolib.Test(t, files) -	b.AssertFileContent("public/s1/p1/index.html", `+	b.AssertFileContent(+		"public/s1/p1/index.html", ` 		<meta itemprop="name" content="p1"> 		<meta itemprop="description" content="a b and c can’t."> 		<meta itemprop="datePublished" content="2024-04-24T08:00:00-07:00">@@ -475,27 +494,32 @@ keywords: [k1,k2] 	)  	// Description from content excerpt-	b.AssertFileContent("public/s1/p2/index.html",+	b.AssertFileContent(+		"public/s1/p2/index.html", 		`<meta itemprop="description" content="d e and f can’t.">`, 	)  	// Description from front matter summary-	b.AssertFileContent("public/s1/p3/index.html",+	b.AssertFileContent(+		"public/s1/p3/index.html", 		`<meta itemprop="description" content="g h and i can’t.">`, 	)  	// The markdown is intentionally not rendered to HTML.-	b.AssertFileContent("public/s1/p4/index.html",+	b.AssertFileContent(+		"public/s1/p4/index.html", 		`<meta itemprop="description" content="j k and **l** can&#39;t.">`, 	)  	// The markdown is intentionally not rendered to HTML.-	b.AssertFileContent("public/s1/p5/index.html",+	b.AssertFileContent(+		"public/s1/p5/index.html", 		`<meta itemprop="description" content="m n and **o** can&#39;t.">`, 	)  	// Front matter keywords-	b.AssertFileContent("public/s1/p6/index.html",+	b.AssertFileContent(+		"public/s1/p6/index.html", 		`<meta itemprop="keywords" content="k1,k2">`, 	) @@ -586,9 +610,10 @@ title: ''  	b := hugolib.Test(t, files) -	b.AssertFileContent("public/s1/p1/index.html", `+	b.AssertFileContent(+		"public/s1/p1/index.html", ` 		<meta name="twitter:card" content="summary_large_image">-		<meta name="twitter:image" content="/a.jpg">+		<meta name="twitter:image" content="https://example.org/a.jpg"> 		<meta name="twitter:title" content="p1"> 		<meta name="twitter:description" content="a b and c can’t."> 		<meta name="twitter:site" content="@foo">@@ -596,23 +621,27 @@ title: '' 	)  	// Description from content excerpt-	b.AssertFileContent("public/s1/p2/index.html",+	b.AssertFileContent(+		"public/s1/p2/index.html", 		`<meta name="twitter:card" content="summary">`, 		`<meta name="twitter:description" content="d e and f can’t.">`, 	)  	// Description from front matter summary-	b.AssertFileContent("public/s1/p3/index.html",+	b.AssertFileContent(+		"public/s1/p3/index.html", 		`<meta name="twitter:description" content="g h and i can’t.">`, 	)  	// The markdown is intentionally not rendered to HTML.-	b.AssertFileContent("public/s1/p4/index.html",+	b.AssertFileContent(+		"public/s1/p4/index.html", 		`<meta name="twitter:description" content="j k and **l** can&#39;t.">`, 	)  	// The markdown is intentionally not rendered to HTML.-	b.AssertFileContent("public/s1/p5/index.html",+	b.AssertFileContent(+		"public/s1/p5/index.html", 		`<meta name="twitter:description" content="m n and **o** can&#39;t.">`, 	) tpl/tplimpl/tplimpl_integration_test.goindex 647500207..b1f03a50a 100644@@ -168,6 +168,7 @@ func TestSitemap(t *testing.T) {  	files := ` -- hugo.toml --+baseURL = "/" disableKinds = ['home','rss','section','taxonomy','term'] [sitemap] disable = true@@ -188,28 +189,32 @@ title: p2  	// Test A: Exclude all pages via project config. 	b := hugolib.Test(t, files)-	b.AssertFileContentExact("public/sitemap.xml",+	b.AssertFileContentExact(+		"public/sitemap.xml", 		"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n  xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n  \n</urlset>\n", 	)  	// Test B: Include all pages via project config. 	files_b := strings.ReplaceAll(files, "disable = true", "disable = false") 	b = hugolib.Test(t, files_b)-	b.AssertFileContentExact("public/sitemap.xml",+	b.AssertFileContentExact(+		"public/sitemap.xml", 		"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n  xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n  <url>\n    <loc>/p1/</loc>\n  </url><url>\n    <loc>/p2/</loc>\n  </url>\n</urlset>\n", 	)  	// Test C: Exclude all pages via project config, but include p1 via front matter. 	files_c := strings.ReplaceAll(files, "p1_disable: foo", "disable: false") 	b = hugolib.Test(t, files_c)-	b.AssertFileContentExact("public/sitemap.xml",+	b.AssertFileContentExact(+		"public/sitemap.xml", 		"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n  xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n  <url>\n    <loc>/p1/</loc>\n  </url>\n</urlset>\n", 	)  	// Test D:  Include all pages via project config, but exclude p1 via front matter. 	files_d := strings.ReplaceAll(files_b, "p1_disable: foo", "disable: true") 	b = hugolib.Test(t, files_d)-	b.AssertFileContentExact("public/sitemap.xml",+	b.AssertFileContentExact(+		"public/sitemap.xml", 		"<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>\n<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n  xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">\n  <url>\n    <loc>/p2/</loc>\n  </url>\n</urlset>\n", 	) }