From 3466884e364d0df39394742697d6fa0b37d49e64 Mon Sep 17 00:00:00 2001 From: Nico Date: Sat, 20 Jun 2020 15:00:25 +0200 Subject: 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 --- hugolib/site.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'hugolib/site.go') diff --git a/hugolib/site.go b/hugolib/site.go index 5507d7a78..ac65931d0 100644 --- a/hugolib/site.go +++ b/hugolib/site.go @@ -1209,8 +1209,10 @@ func (s *Site) render(ctx *siteRenderContext) (err error) { return } - if err = s.renderRobotsTXT(); err != nil { - return + if ctx.multihost { + if err = s.renderRobotsTXT(); err != nil { + return + } } if err = s.render404(); err != nil { -- cgit v1.2.3