Deploy site on github with Toha Template

Hi all,
I’m really newbie in programming, especially in the use of git and GitHub,
I have made a blog with the quick start of the Toha theme.
Now following this guide “Deploy site in Github Pages” I’m trying to deploy it on GitHub.
The application runs locally because I have downloaded Bootstrap but when I push the blog on GitHub the actions give to me these errors.

Run hugo --minify
hugo: downloading modules …
hugo: collected modules in 2819 ms
Start building sites … 
hugo v0.109.0-47b12b83e636224e5e601813ff3e6790c191e371+extended linux/amd64 BuildDate=2022-12-23T10:38:11Z VendorInfo=gohugoio
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/application.js:2:7": Could not resolve "bootstrap"
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/application.js:3:7": Could not resolve "@fortawesome/fontawesome-free/js/all"
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/features/darkmode/darkreader.js:1:54": Could not resolve "darkreader"
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/features/syntaxhighlight/hljs.js:1:17": Could not resolve "highlight.js"
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/features/videoplayer/plyr.js:1:17": Could not resolve "plyr"
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/pages/home.js:1:21": Could not resolve "ityped"
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/pages/note.js:1:25": Could not resolve "imagesloaded"
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/pages/search.js:1:17": Could not resolve "fuse.js"
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/pages/search.js:2:17": Could not resolve "mark.js"
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/sections/projects.js:1:22": Could not resolve "filterizr"
ERROR 2023/01/14 15:52:14 js.Build failed: "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/sections/publications.js:1:22": Could not resolve "filterizr"
Error: Error building site: JSBUILD: failed to transform "scripts/application.js" (text/javascript): "/tmp/hugo_cache/modules/filecache/modules/pkg/mod/github.com/hugo-toha/toha/v4@v4.0.0-20230105191255-374b4019d89d/assets/scripts/application.js:1:7": Could not resolve "popper.js"
Total in 5712 ms
Error: Process completed with exit code 255.

Can anyone tell me why there are these errors and how I can fix them?
Thanks in advantage for any tips and help :slight_smile:

This is my repo

To build your site you need to install the Node.js dependencies. When you’re building locally, at some point you did something like npm ci or npm install. Your GitHub workflow does not include that step.

Insert this into your workflow file before you build with Hugo:

- name: Install Node.js dependencies
  run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"

I’ve been using the Hugo “starter” workflow provided by GitHub. It includes the step above, and also installs the Dart Sass transpiler.

.github/workflows/hugo.yml
# Sample workflow for building and deploying a Hugo site to GitHub Pages
name: Deploy Hugo site to Pages

on:
  # Runs on pushes targeting the default branch
  push:
    branches: ["main"]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
  contents: read
  pages: write
  id-token: write

# Allow one concurrent deployment
concurrency:
  group: "pages"
  cancel-in-progress: true

# Default to bash
defaults:
  run:
    shell: bash

jobs:
  # Build job
  build:
    runs-on: ubuntu-latest
    env:
      HUGO_VERSION: 0.109.0
      TZ: America/Los_Angeles
    steps:
      - name: Install Hugo CLI
        run: |
          wget -O ${{ runner.temp }}/hugo.deb https://github.com/gohugoio/hugo/releases/download/v${HUGO_VERSION}/hugo_extended_${HUGO_VERSION}_linux-amd64.deb \
          && sudo dpkg -i ${{ runner.temp }}/hugo.deb
      - name: Install Dart Sass Embedded
        run: sudo snap install dart-sass-embedded
      - name: Checkout
        uses: actions/checkout@v3
        with:
          submodules: recursive
      - name: Setup Pages
        id: pages
        uses: actions/configure-pages@v2
      - name: Install Node.js dependencies
        run: "[[ -f package-lock.json || -f npm-shrinkwrap.json ]] && npm ci || true"
      - name: Build with Hugo
        env:
          # For maximum backward compatibility with Hugo modules
          HUGO_ENVIRONMENT: production
          HUGO_ENV: production
        run: |
          hugo \
            --minify \
            --baseURL "${{ steps.pages.outputs.base_url }}/"
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v1
        with:
          path: ./public

  # Deployment job
  deploy:
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    runs-on: ubuntu-latest
    needs: build
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v1


1 Like

Thank you very much.
Yes on my local machine, I have used npm for downloading Bootstrap. I have added npm and Dart Sass transpiler I think.
Now a new error appeared :frowning:

Run peaceiris/actions-gh-pages@v3.8.0
[INFO] Usage https://github.com/peaceiris/actions-gh-pages#readme
Dump inputs
Setup auth token
Prepare publishing assets
Setup Git config
Create a commit
Push the commit or tag
  /usr/bin/git push origin gh-pages
  remote: Permission to Giu-seppe/Giu-seppe.github.io.git denied to github-actions[bot].
  fatal: unable to access 'https://github.com/Giu-seppe/Giu-seppe.github.io.git/': The requested URL returned error: 403
  Error: Action failed with "The process '/usr/bin/git' failed with exit code 128"

It seems like the actions don’t have permission but all the actions are enabled

I checked “Allow all actions and reusable workflow”

What happens if you replace the current workflow with the example that I provided? Obviously, save the old one under a different directory so you can revert the change if you need to.

1 Like

It worked!! :smiley:
Where did you find Hugo’s starter?
I find only this in the documentation Build Hugo With GitHub Action
Thank you very much for the help :slightly_smiling_face:

When you first enable GitHub Pages, it will suggest the Hugo “starter” workflow.

https://docs.github.com/en/actions/using-workflows/using-starter-workflows

1 Like

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