On local, everything is fine tuned, I just need to make some posts !
But online I’m having troubles, I can’t seem to find why github actions are not working. I copied the deploy.yml file from the hugo-theme-stack-starter to my website repository.
I changed the master branch to main to fit my repo, but nothing is happening, my website isn’t rendered.
Should I redirect something to make it build properly using my submodule ? The starter guide is working on my end so I don’t understand what could be changing apart from the theme installation method.
I just seem to see a XML file instead of the whole website.
Run hugo --minify --gc
Start building sites …
hugo v0.115.3-5c2e014a5150553a9fa4f9c1eb7dc4db89c0f1ab+extended linux/amd64 BuildDate=2023-07-13T16:11:34Z VendorInfo=gohugoio
WARN found no layout file for "html" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN 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.
WARN found no layout file for "html" for kind "home": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN found no layout file for "html" for kind "section": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN found no layout file for "html" for kind "taxonomy": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN found no layout file for "html" for layout "search" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
WARN found no layout file for "json" for layout "search" for kind "page": You should create a template file which matches Hugo Layouts Lookup Rules for this combination.
| EN
-------------------+-----
Pages | 4
Paginator pages | 0
Non-page files | 0
Static files | 1
Processed images | 0
Aliases | 3
Sitemaps | 1
Cleaned | 0
Total in 19 ms
So indeed it doesn’t find my theme, but I don’t know yet what to do.
Yes I did, but nothing helped yet. The files for the theme are here in my repo but it seems like the building process from github workflow isn’t capable of building the site using the theme.
Alright then, the fix provided by a long discussion with our dear chatGPT helped me :
It seems like the issue with the GitHub Workflow not finding the theme might be related to the submodule not being cloned during the default actions/checkout@v2 step. When you use the actions/checkout@v2, it only clones the main repository, but not the submodules.
To ensure the submodule is also cloned, you need to add an extra step before the actions/checkout@v2. You can use git commands directly in the workflow to ensure the submodule is cloned along with the main repository.
Here’s how you can modify your workflow:
yaml
name: Deploy to Github Pages
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the
# added or changed files to the repository.
contents: write
steps:
# Ensure the submodule is cloned along with the main repository
- name: Check out the code
uses: actions/checkout@v2
with:
submodules: 'recursive' # Add this line to clone submodules
- name: Cache Hugo resources
uses: actions/cache@v2
env:
cache-name: cache-hugo-resources
with:
path: resources
key: ${{ env.cache-name }}
- uses: actions/setup-go@v2
with:
go-version: "^1.17.0"
- run: go version
- name: Cache Go Modules
uses: actions/cache@v2
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: "latest"
extended: true
- name: Build
run: hugo --minify --gc
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@4.1.4
with:
branch: gh-pages
folder: public
clean: true
single-commit: true
By adding the submodules: 'recursive' line under the actions/checkout@v2 step, you are telling GitHub Actions to clone the submodules recursively, ensuring that your theme submodule will be available during the build process.