From eac553de41337cc0e1f62892447942d92af3fd15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Thu, 23 Dec 2021 08:57:28 +0100 Subject: [PATCH] Make sure we always create the /public folder MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is related to #8166 – if the /public folder did not exist, you had no /static files and had static files in /content root, then you would get a "no such file or directory" error. --- hugolib/filesystems/basefs.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go index a51cc4b2702..32746bc165f 100644 --- a/hugolib/filesystems/basefs.go +++ b/hugolib/filesystems/basefs.go @@ -428,6 +428,11 @@ func NewBase(p *paths.Paths, logger loggers.Logger, options ...func(*BaseFs) err logger = loggers.NewWarningLogger() } + // Make sure we always have the /public folder ready to use. + if err := fs.Destination.Mkdir(p.AbsPublishDir, 0777); err != nil && !os.IsExist(err) { + return nil, err + } + publishFs := hugofs.NewBaseFileDecorator(afero.NewBasePathFs(fs.Destination, p.AbsPublishDir)) sourceFs := hugofs.NewBaseFileDecorator(afero.NewBasePathFs(fs.Source, p.WorkingDir))