Host on GitHub Pages: Unable to locate config file or config directory

Hi everyone,

I am very new to Hugo and don’t have enough programming knowledge:( I just started building my website following the step-by-step guide on the Hugo website. After completing the quick start, I tried to host my website on GitHub, but I encountered the error message ‘Unable to locate config file or config directory.’"

I have checked the yaml and toml files, they are in the root directory. I have replaced the website address in hugo.toml file by the one provided by GitHub. Can anyone help me with this? Many thanks in advance!

Looks like you are building the wrong branch

Maybe main vs master.

If not that. A link to the repo would help.

Hi Irkode,

Thank you very much for your help! I just double-checked. The main branch is correct. Here is the link:) GitHub - luolinlin1201/Im00_im00. Many thanks in advance!

  • repository structure:

    you should not commit these. they are generated by hugo. Bu default hugo does not delete them when builing, so you will get unpredictable results.

    • public
    • resourcs
    • .hugo_build.lock

    delete them and it’s a good idea to add them to .gitignore file to not re-commit accidently

  • don’t use two config files

    remove obsolete config.yaml.

  • fix String value in hugo.toml

    as seen in the latest builds there’s a quoting error (use double quotes for title)

    baseURL = ''
    languageCode = 'en-us'
    title = "00's blog"
    theme = 'ananke'
  • fix your workflow

    use this in lines 60-63

              hugo \
              --gc \
              --minify \
              --baseURL "${{ steps.pages.outputs.base_url }}/"

Thank you very much irkode! It worked! But I met another unexpected issue: Error: failed to load config: “/home/runner/work/Im00_im00/Im00_im00/hugo.toml:3:13”: unmarshal failed: toml: expected newline but got U+0073 ‘s’
I have checked my codes and it seems all good. Could you help me with this? Many thanks in advance!

Your last run had no errors:

To clarify…

Adding .hugo_build.lock to source control does not cause unpredictable results, but there’s no reason to include it.

Adding the public directory to source control does not cause unpredictable results, but in a CI/CD workflow the directory is not used, so there’s no reason to include it.

Adding the resources directory to source control does not cause unpredictable results, and its presence can reduce CI/CD build times. For example, if a site processes 1000 images, the results are cached (by default) within the resources directory. If you include this directory in source control, the cached images will be used when building your site. From a cost and performance standpoint this can be a big win.

Thank you so much!! It’s done!!

sry for that confusion:

  • agreed: no harm .hugo_build.lock but there’s no reason to include it.

  • regarding public not used

    commonly seen GitHub pages wf:

         run: |
            hugo \
              --gc \
              --minify \
              --baseURL "${{ steps.pages.outputs.base_url }}/"
        - name: Upload artifact
          uses: actions/upload-pages-artifact@v3
            path: ./public

    so if there’s anything in public that is not touched it will be pushed to the site. We already had some problems with ancient content there, that affected the published site. So for that kind of workflow definition public may affect.

  • i never digged in details on resources.

    I would follow you there if the maintainer keeps the resources clean (seen tons of fingerprinted development files there)

    Question: as these are build results would’t it be better to use the ci/cd to cache them?

Sure, if (a) the providers supports that, and (b) a novice or intermediate understands how to configure it.

For example, Netlify supports this, but I’ll bet 96% of all Hugo sites hosted by Netlify don’t take advantage of this for images.

My expectation is… if you don’t want it in source control, don’t add it to source control.

:- :innocent: indeed one should

But from my experience many unexperienced users (git / hugo) just

git add .
git push

not based on a decision why or why not.

Also, at least when hosting with GitHub pages, I am unable to reproduce the behavior you describe.

See commit history:

And live site:

Post 4 is present in the repo’s public directory, but not in the build.

it’s there:


Gotcha. I guess I don’t care if it’s not listed.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.