mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-21 21:35:28 +02:00
Create robots.txt in the domain root directory
Before a robots.txt is created in every Site. So in public/robots.txt if there are no languages (was correct). But if there are multiple languages in every language directory, too (was wrong). If defaultContentLanguageInSubdir is true, no language is created into the root directory, so no robots.txt is in the root directory (was wrong). If multihosts are configured for each language, that is the only case where one robots.txt must be created in each language directory (was correct). I've changed the behaviour, that only in the multihost case the robots.txt is created in the language directories. In any other case it is created in public/robots.txt. I've also added tests that files are not created in the wrong directories. Fixes #5160 See also #4193
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
6ff435aa3f
commit
3466884e36
@@ -19,6 +19,7 @@ disablePathToLower = true
|
||||
defaultContentLanguage = "fr"
|
||||
defaultContentLanguageInSubdir = false
|
||||
staticDir = ["s1", "s2"]
|
||||
enableRobotsTXT = true
|
||||
|
||||
[permalinks]
|
||||
other = "/somewhere/else/:filename"
|
||||
@@ -73,6 +74,12 @@ languageName = "Nynorsk"
|
||||
c.Assert(pageWithURLInFrontMatter.RelPermalink(), qt.Equals, "/docs/superbob/")
|
||||
b.AssertFileContent("public/en/superbob/index.html", "doc3|Hello|en")
|
||||
|
||||
// the domain root is the language directory for each language, so the robots.txt is created in the language directories
|
||||
b.AssertFileContent("public/en/robots.txt", "robots|en")
|
||||
b.AssertFileContent("public/fr/robots.txt", "robots|fr")
|
||||
b.AssertFileContent("public/nn/robots.txt", "robots|nn")
|
||||
b.AssertFileDoesNotExist("public/robots.txt")
|
||||
|
||||
// check alias:
|
||||
b.AssertFileContent("public/en/al/alias1/index.html", `content="0; url=https://example.com/docs/superbob/"`)
|
||||
b.AssertFileContent("public/en/al/alias2/index.html", `content="0; url=https://example.com/docs/superbob/"`)
|
||||
|
Reference in New Issue
Block a user