Error building site (github page)

Hi,
First of all, Hugo (with PaperMod theme) is great.
But, the problem I have now, is that I can’t deploy my site with github page.

However, I have no error when I run it locally hugo server -D --minify.

I think the problem is related to the PaperMod theme, but I don’t understand why…

But with github actions I have an error in the build:

Run hugo --minify
Start building sites ...
hugo v0.101.0-466fa43c16709b4483689930a4f9ac8add5c9f66+extended linux/amd64 BuildDate=2022-06-16T07:09:16Z VendorInfo=gohugoio
Error: Error building site: failed to render pages: render of "page" failed: "/home/runner/work/jeans-github.github.io/jeans-github.github.io/themes/PaperMod/layouts/_default/baseof.html:5:8": execute of template failed: template: _default/single.html:5:8: executing "_default/single.html" at <partial "head.html" .>: error calling partial: execute of template failed: template: partials/templates/opengraph.html:45:17: executing "partials/templates/opengraph.html" at <index $siteSeries ($name | urlize)>: error calling index: index of untyped nil
Total in 129 ms
Error: Process completed with exit code 255

Having made slight changes in the theme to suit my needs, I had not initially added the theme with git submodule. (that’s why there is nothing under the line 16 in gh-pages.yml (for github actions))
As it didn’t work, I tried adding the theme with git submodule (without making any modifications on the theme), but same error.

Here is my github repo (the theme has been slightly modified, like just in header.css for example). You can clone it and try it locally, it’ll works (I use hugo latest extended version).

Thanks in advance for your time

You probably have at least one page without whatever frontmatter defines $siteSeries (or maybe even a taxonomy or taxonomy term). You likely need to make the using of $siteSeries conditional around line 45 of partials/templates/opengraph.html.

Hello, many thanks for your answer and your time.

But, I’m sorry, I don’t really know (and also have the knowledge) how to make the change you said.
How could I make $siteSeries conditional?

And also, why can I run this site locally but not with github actions?

Thank again in advance

Sorry, I’ve taken a closer look now, and I see

-D Means build with drafts, but your GA has:

which doesn’t include draft pages. It seems there is a dependency on at least one draft page by a non-draft page. Without really taking a thorough look, my guess would be that your ‘series’ frontmatter on some non-draft page references a draft page.

If no one else gets to this sooner than I and that’s not enough of a hint, I will to take a closer look sometime this week. (Conditionalizing the series would probably help as well, but I’ll have to find some time to give a more detailed answer on how to do that for this theme).

1 Like

Thanks for your quick reply, I now better understand the problem, I continue to investigate while waiting for your more complete feedback.
edit: another weird thing, is that I can run hugo server -D and it works without errors, but running only hugo -D doesn’t work (and I get the error).

First, instead of modifying a theme file, override it by placing a copy in the layouts directory in the root of your project. This allows you to update the theme to a newer version without losing your changes.

Second, the referenced error is not thrown when you run hugo server because of this line. The hugo.IsProduction method returns false when you run hugo server, and it returns true when you run hugo.[1] When running hugo server the opengraph template is never called.

Finally, the referenced error occurs because the opengraph template expects to find a series taxonomy if you have defined series in the front matter of any content page. To fix, add this to the root of your site configuration:

taxonomies:
  category: categories
  series: series
  tag: tags

  1. This assumes that (a) you are not specifying the environment on the command line, and (b) you are not specifying the environment with an OS environment variable. ↩︎

2 Likes

Thanks a lot again for your detailed answer.
So, if I understand correctly, I should move all the theme folder (so in my case the PaperMod folder) to /layouts/PaperMod/?
So it should be something like this (again in my case):

.
├── archetypes
├── content
│   └── ...
├── data
├── layouts
│   ├── PaperMod
│   │   ├── assets
│   │   ├── layouts
│   │   │   ├── _default
│   │   │   └── ...
│   │   └── ...
│   └── shortcodes
├── public
├── resources
│   └── ...
├── static
│   ├── archetypes
│   └── ...
└── themes (empty)

And with a file structure like this (and without changing my gh workflow) even if I make changes in the theme, it will be updated (if there are new updates) without changing my modifications?

And once again thank you for your explanations, I understand much better now the issue I had. Your solution solved the problem.

1 Like

No.

Let’s say you’ve installed a theme named foo:

themes
└── foo/
    └── layouts/
        ├── _default/
        │   ├── baseof.html
        │   ├── home.html
        │   ├── list.html
        │   └── single.html
        └── partials/
            └── head.html

To override the single template and the head partial:

layouts
├── _default/
│   └── single.html  <-- overrides themes/foo/layouts/_default/single.html
└── partials/
    └── head.html    <-- overrides themes/foo/layouts/partials/head.html
themes
└── foo/
    └── layouts/
        ├── _default/
        │   ├── baseof.html
        │   ├── home.html
        │   ├── list.html
        │   └── single.html
        └── partials/
            └── head.html

Oh ok, that actually makes more sense :smile:
Thanks again!

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