Hugo Not Generating HTML files Upon Build

Here is my repo: GitHub - joesan/joesan-me: My personal blogging website

What I’m trying to do is basically the following:

  1. Upon commit to the master branch, trigger the GitHub actions
  2. Checkout a copy of the master branch, install hugo, build and copy the contents of the public folder to a new branch called gh-pages
  3. The gh-pages is then configured to serve the GitHub pages
  4. Using my custom domain name, the page is redirected to GitHub pages when called.

Here is what I’m doing in my main.yaml:

      - name: Generate HTML
        run: hugo --minify
      - name: Commit and push to target branch
        run: |-
          hugo version
          echo "PRINTING CURRENT DIRECTORY......"
          pwd
          echo "PRINTING LS DIRECTORY......"
          ls -la
          cd public
          echo "PRINTING LS PUBLIC DIRECTORY......"
          ls -la
          git config --global user.email "workflow-bot@bigelectrons.com"
          git config --global user.name "workflow-bot"
          git checkout --orphan $TARGET_BRANCH
          mv public ..
          rm -rf *
          mv ../public/* .
          touch .nojekyll
          touch README.md
          echo 'https://www.bigelectrons.com - SITE GENERATED USING HUGO' > README.md
          touch CNAME
          echo 'bigelectrons.com' > CNAME
          rm -rf .github/
          rm -Rf .gitignore
          rm -Rf .idea
          git add .
          git commit -m "generated using hugo build"
          git push --set-upstream origin $TARGET_BRANCH --force

I additionally see the following in my logs:

hugo --minify

[3](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:3) shell: /usr/bin/bash -e {0}

[4](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:4) env:

[5](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:5) TARGET_BRANCH: gh-pages

[7](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:7)Start building sites …

[8](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:8)hugo v0.90.1+extended linux/amd64 BuildDate=2021-12-10T15:22:29Z

[9](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:9)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

[10](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:10)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for layout "archives" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

[11](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:11)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for layout "navo" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

[12](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:12)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for layout "projects" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

[13](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:13)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

[14](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:14)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

[15](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:15)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

[16](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:16)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

[17](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:17)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

[18](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:18)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

[19](https://github.com/joesan/bigElectrons/runs/4498309832?check_suite_focus=true#step:4:19)WARN 2021/12/12 14:38:51 found no layout file for "HTML" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.

Is that anything that I should pay attention to?

Yes, all of it.

Recommendations:

  1. Make sure you can build the site locally without errors or warnings before trying to deploy.

  2. Use an existing, proven workflow:

    See: https://gohugo.io/hosting-and-deployment/hosting-on-github

  3. Once you have that working, make workflow modifications as needed.

On local machine it works flawlessly:

joesan@joesan-InfinityBook-S-14-v5:~/Projects/Private/github-docs/bigElectrons$ hugo --minify

                   | EN   
-------------------+------
  Pages            | 147  
  Paginator pages  |  13  
  Non-page files   |   0  
  Static files     |  63  
  Processed images |   0  
  Aliases          |  53  
  Sitemaps         |   1  
  Cleaned          |   0  

Total in 274 ms
joesan@joesan-InfinityBook-S-14-v5:~/Projects/Private/github-docs/bigElectrons$

Which version of Hugo are you running locally?
Which version of Hugo are you running on GH?

Local:

joesan@joesan-InfinityBook-S-14-v5:~/Projects/Private/github-docs/bigElectrons$ hugo version
Hugo Static Site Generator v0.68.3/extended linux/amd64 BuildDate: 2020-03-25T06:15:45Z

GitHub build:

Run hugo version

[30](https://github.com/joesan/bigElectrons/runs/4498357591?check_suite_focus=true#step:5:30)hugo v0.90.1+extended linux/amd64 BuildDate=2021-12-10T15:22:29Z

v0.68.3 was released almost two years ago. Time to upgrade your local machine.

But that is strange as the older version works without producing any errors. I will update my local version and try and then post the results.

How to I upgrade the version on my local machine?

joesan@joesan-InfinityBook-S-14-v5:~$ sudo apt install hugo
Reading package lists... Done
Building dependency tree       
Reading state information... Done
hugo is already the newest version (0.68.3-1)

I managed to update the local machine and on my local machine it looks ok:

joesan@joesan-InfinityBook-S-14-v5:~/Projects/Private/github-docs/bigElectrons$ hugo --minify
Start building sites … 
hugo v0.90.1+extended linux/amd64 BuildDate=2021-12-10T15:22:29Z

                   | EN   
-------------------+------
  Pages            | 147  
  Paginator pages  |  13  
  Non-page files   |   0  
  Static files     |  63  
  Processed images |   0  
  Aliases          |  53  
  Sitemaps         |   1  
  Cleaned          |   0  

Total in 312 ms
joesan@joesan-InfinityBook-S-14-v5:~/Projects/Private/github-docs/bigElectrons$ cd public/
drwxr-xr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  .
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  ..
.rw-rw-r-- joesan joesan    0 B  Sat Dec 11 08:17:43 2021  .gitignore
.rw-rw-r-- joesan joesan 13.7 KB Sun Dec 12 16:43:51 2021  404.html
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  about
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  about-hugo
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  about-us
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  categories
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  contact
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  css
drwxr-xr-x joesan joesan    4 KB Sat Dec 11 08:17:43 2021  fonts
drwxr-xr-x joesan joesan    4 KB Sat Dec 11 20:16:38 2021  icons
drwxr-xr-x joesan joesan    4 KB Sat Dec 11 08:17:43 2021  images
.rw-rw-r-- joesan joesan 46.6 KB Sun Dec 12 16:43:51 2021  index.html
.rw-rw-r-- joesan joesan 40.9 KB Sun Dec 12 16:43:51 2021  index.xml
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  js
drwxr-xr-x joesan joesan    4 KB Sat Dec 11 21:15:23 2021  logos
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  page
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  post
.rw-rw-r-- joesan joesan 11.6 KB Sun Dec 12 16:43:51 2021  sitemap.xml
drwxrwxr-x joesan joesan    4 KB Sun Dec 12 16:43:51 2021  tags
joesan@joesan-InfinityBook-S-14-v5:~/Projects/Private/github-docs/bigElectrons/public$

I now seriously do not understand why it should not work on the remote GitHub page?

Get this working, then modify your workflow as needed.

1 Like

I do not want to use the GitHub actions and I do not understand how adding the GitHub actions would make my issue vanish? Is there any relation to this?

Yes. You can learn from something that has been proven to work for many, many sites.

1 Like

Ok I was able to make some progress. But now, the css seems to be messed up.

Had a look at the developer tools. Seems CORS issue is blocking CSS from being rendered.

Access to CSS stylesheet at 'https://www.bigelectrons.com/css/styles.01869c76e4757810d94ecbdccadba853d9d01d9416dfeb113df02e1479ff8b36e284e8bfeb3e8f353f2fdcdcbbdfcf27e558dbda96eb6341bfc304d55cd9e986.css' from origin 'https://bigelectrons.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

You are serving your site from https://bigelectrons.com/ but you have set the baseURL in site config to https://www.bigelectrons.com/.

Yes, figured that out. Seems everything is fine now. Thanks for the help. I however do not understand why the custom script that I wrote would not work.