Unable to deploy hugo blog


i’m unable to deploy my hugo blog to netlify. The build throws can’t find config file error and I have my netlify.toml file in my base dir.

1:40:43 PM:   1. build.command from netlify.toml                            
1:40:43 PM: ────────────────────────────────────────────────────────────────
1:40:43 PM: ​
1:40:43 PM: $ hugo --gc --minify
1:40:44 PM: Error: Unable to locate config file or config directory. Perhaps you need to create a new site.
1:40:44 PM:        Run `hugo help new` for details.
1:40:44 PM: Total in 1 ms
1:40:44 PM: ​
1:40:44 PM: ────────────────────────────────────────────────────────────────
1:40:44 PM:   "build.command" failed                                        
1:40:44 PM: ────────────────────────────────────────────────────────────────
1:40:44 PM: ​
1:40:44 PM:   Error message
1:40:44 PM:   Command failed with exit code 255: hugo --gc --minify
1:40:44 PM: ​
1:40:44 PM:   Error location
1:40:44 PM:   In build.command from netlify.toml:
1:40:44 PM:   hugo --gc --minify
1:40:44 PM: ​
1:40:44 PM:   Resolved config

link to repo: GitHub - shosenwales/my-blog

Hey @shosenwales

Unfortunately the portion of the build log doesn’t give a whole lot of useful information. Based on a quick look at the repository you shared, I suggest you haven’t set the base directory. The hugo files are in the blog directory in the repository rather than at the root of the repository. This means you need to set the base directory to blog. You will also need to move the netlify.toml file into the blog directory as well.

HI @coelmay thanks for looking into it. after setting the base directory and moving the netlify.toml file into the blog directory, deployment was successful. When I try to access the deployed site, I get a “page not found error” . link : https://epic-hoover-9951c7.netlify.app/

A step in the right direction then @shosenwales :slight_smile:

What is the publish directory set to in the Build settings? If you are using the default build path public, the publish directory should have the value blog/public (note the blog part will auto populate the field as that is the base directory value.)

Alright @coelmay , i just changed the value to blog/public . i committed my changes to git, what do i do on the netlify end?

You shouldn’t need to do anything else.

Can you share the link to the last deploy log.

The theme isn’t being found because the .gitmodules file is in the root of the repository, not in the base directory.
You need to a) move the .gitmodules file into the blog directory, and b) change the submodule path

This is what is there

[submodule "blog/themes/hugo-coder"]
	path = blog/themes/hugo-coder
	url = https://github.com/luizdepra/hugo-coder.git

This is what it should change to once inside the blog directory

[submodule "themes/hugo-coder"]
	path = themes/hugo-coder
	url = https://github.com/luizdepra/hugo-coder.git

i just did this and refreshed the netlifyapp page, but it is still the same.

last deploy log:

11:06:49 PM: Build ready to start
11:06:52 PM: build-image version: 122b31996ccaffd45d820a452d6227f8312110cc (focal)
11:06:52 PM: build-image tag: v4.5.3
11:06:52 PM: buildbot version: 7383bb8971c718de9618a700ec5049cb71af7102
11:06:52 PM: Fetching cached dependencies
11:06:52 PM: Failed to fetch cache, continuing with build
11:06:52 PM: Starting to prepare the repo for build
11:06:52 PM: No cached dependencies found. Cloning fresh repo
11:06:52 PM: git clone https://github.com/shosenwales/my-blog
11:06:53 PM: Preparing Git Reference refs/heads/main
11:06:54 PM: Parsing package.json dependencies
11:06:55 PM: No build steps found, continuing to publishing
11:06:55 PM: Starting to deploy site from '/'
11:06:55 PM: Creating deploy tree 
11:06:55 PM: Creating deploy upload records
11:06:55 PM: 35 new files to upload
11:06:57 PM: Starting post processing
11:06:55 PM: 0 new functions to upload
11:06:57 PM: Finished processing build request in 5.083911302s
11:06:57 PM: Post processing - HTML
11:06:57 PM: Post processing - header rules
11:06:57 PM: Post processing - redirect rules
11:06:58 PM: Post processing done
11:06:59 PM: Site is live ✨

Apologies, editing the .gitmodules file directly does not work. You would need to re-add the submodule.

I forked your repository (coelmay/my-blog), moved everything from blog to the repository too, added the theme submodule using the --force flag, changed the netlify.toml as required and deployed successfully. Deploy log is here