Skip to content

Commit 273d9f6

Browse files
committedMay 27, 2023
commands: Fail the build when no config file or config dir
Fixes #11019
1 parent a6257d8 commit 273d9f6

File tree

4 files changed

+16
-0
lines changed

4 files changed

+16
-0
lines changed
 

‎commands/hugobuilder.go

+4
Original file line numberDiff line numberDiff line change
@@ -1019,6 +1019,10 @@ func (c *hugoBuilder) loadConfig(cd *simplecobra.Commandeer, running bool) error
10191019
return err
10201020
}
10211021

1022+
if len(conf.configs.LoadingInfo.ConfigFiles) == 0 {
1023+
return errors.New("Unable to locate config file or config directory. Perhaps you need to create a new site.\nRun `hugo help new` for details.")
1024+
}
1025+
10221026
c.conf = conf
10231027
if c.onConfigLoaded != nil {
10241028
if err := c.onConfigLoaded(false); err != nil {
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
hugo
3+
! stderr .
4+
5+
-- config/_default/hugo.toml --
6+
baseURL = "https://example.com/"

‎testscripts/commands/hugo__flags.txt

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ grep '<body>Home' newpublic/index.html
1111
hugo --quiet
1212
! stdout .
1313

14+
-- hugo.toml --
15+
title = "Hugo Test"
1416
-- myconfig.toml --
1517
baseURL = "http://example.org/"
1618
disableKinds = ["RSS", "sitemap", "robotsTXT", "404", "taxonomy", "term"]
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
! hugo
3+
4+
stderr 'Unable to locate config file or config directory'

0 commit comments

Comments
 (0)
Please sign in to comment.