Error calling ExecuteAsTemplate: type <nil>

So I’m setting up an existing project on a new computer.

Copied old project folder onto the new computer.

I get this:

ERROR 2020/11/07 01:32:26 render of "page" failed: "/home/username/Documents/hugo/project_name/layouts/fragments/baseof.html:14:55": execute of template failed: template: fragments/single.html:14:55: executing "fragments/single.html" at <resources.ExecuteAsTemplate>: error calling ExecuteAsTemplate: type <nil> not supported in Resource transformations

I’ve noticed (on this website) this error occurs when dealing with CSS under certain conditions.

The “offending” bit of code from the Mainroad theme:

{{ $style := resources.Get "css/style.css" | resources.ExecuteAsTemplate "css/style.css" . -}}

I’ve checked the Mainroad source, and I’ve changed nothing there.

New setup:

Hugo Static Site Generator v0.78.1/extended linux/amd64 BuildDate: unknown

The project compiles fine on my old computer:

Hugo Static Site Generator v0.76.5 linux/amd64 BuildDate: 2020-10-14

Any ideas? Thanks.

P.S. I should add that when I installed hugo, I first did sudo apt install hugo then uninstalled it (remove) because it was suggested to install it using homebrew. The version I’m using was installed using brew.

P.P.S. Also, I made a new project (hugo site new whatever) and added the Mainroad theme with no other content, and it worked fine. So the “offending” code isn’t really the problem.

Please do not post long console error messages in a topic’s title.

This pollutes the forum and I always aim to keep it clean.
Also long titles will not get more attention.
This topic belongs in the Support category.

I have amended the topic title and re-categorized it, so please do not undo my changes.

Thank you.

P.S. Also please read the Requesting Help guidelines and share the source code of your project.

Thank you for your interest.

share the source code of your project.

I did share one snippet of code. That is the “offending” line, and the code is identical to functioning Mainroad code, and identical to code that functions on v0.76.5.

Can you be more specific about what you have in mind?

I’m really fishing for anything having to do with either the version changes, installation issues (is brew the wrong way?) or help getting more specific error messages so I can track this thing down myself.

Obviously I’m a little wary about updating Hugo on my other computer right now.

If anyone has any clues…

As per the above link from the Requesting Help guidelines topic:

I’m sorry but there is no link to a source code repository. I do not use Github, and the project is private as of now. I guess that complicates things. Thanks for clarifying.

The nil error means that something is missing in your project.
We cannot guess what is the missing part, without seeing the full project.

If you have the time, try downgrading to the last working Hugo version v0.76.5 on your new computer and then update version-by-version.

Perhaps you will be able to identify which Hugo version broke your project.

Then read the Release Notes for possible clues.

If you do not have the time for the above consider using v0.76.5 for now.

try downgrading to the last working Hugo version v0.76.5 on your new computer and then update version-by-version.

This is probably the right idea. How can I install v0.76.5?

Can you explain how to downgrade?

Sorry to ask such a simple question.

Have a look at:

I think that the simplest way would be to download the v0.76.5 Tarball from the Releases page and manually install it.

Regarding Homebrew I cannot help I’m afraid.

Here’s the link.

So I uninstalled the new version and installed a .deb of v0.76.5 and the hugo issue remains. This means … what? For the sake of my sanity, and due to time pressure, I’m just going to skip installing it on this machine.

I’ll worry about this, if it’s a worry at all, on my next project.

As previously said above, without your project, we are not crystal glass wizards to help further.
But if it is the same Hugo version on the 2 machines, then something in your code and datas is different on the 2 machines …

something in your code and datas is different on the 2 machines

You’re right, but it makes no sense to me. Exact copy, over two ubuntu machines. Permissions of the relevant files identical. It’s a mystery that will not be solved now.

Thanks for your input.

Admin can close this and I’m going to get back to work (on Hugo).

The fact that the project does not generate in v0.76.5 on your new machine whereas it does generate in your old one means that something required by your project’s templates is not there.

Are you relying on external dependencies? Like for instance NPM. Could it be that such an external dependency is missing from the new machine?

Again your issue is not something we can help you with, because we cannot know what’s amiss without seeing the source code of the project.

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