How do I have an HTML file as a page resource?

I just casually went ahead and saved my partial as a page resource for a post, say content/posts/foo/partial.html. However, I think Hugo started evaluating that HTML file, because of which my builds are now failing by stating:

~/G/bitbanged.com main !2 ?1 ❯ hugo server                                  ✘ 255
Start building sites … 
hugo v0.93.1+extended linux/amd64 BuildDate=unknown
Error: Error building site: "/home/subaru/GitHub/bitbanged.com/content/posts/foo/partial.html:1:1": unmarshal failed: invalid character '{' looking for beginning of object key string
Built in 18 ms

How do I tell Hugo to ignore that file?

config.toml

ignoreFiles = ['posts/foo/partial.html']

https://gohugo.io/getting-started/configuration/#ignore-content-and-data-files-when-rendering

Page resources that are content files (md, adoc, org, rst, html) are processed. As you have found, that can be a problem if you want to insert a file’s .Content into something. I’ve handled this in the past by using a global resource instead (put it in the assets directory).

I brought this up for discussion here:
https://github.com/gohugoio/hugo/issues/9197

The original issue title was “Global resource vs page resource discrepancies for markdown files”.

2 Likes

Thanks. I’ll ignore all HTML page resources globally.

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