Don't put unprocessed resources in /public

For reference:

bep’s link above no longer goes to the correct anchor in the docs. The relevant build option is publishResources.

Another option for this use case is to use the global ignoreFiles configuration setting to exclude files.

Also note that hugo ignores any files whose name begins with . or # or whose name ends with ~.

Proposal:

While these features cover many use cases, there are still a few gaps and ugly corner cases.

For example, it is not currently possible to override the ./#/~ filename filter, so e.g. you cannot create a .htaccess file that is published directly as a resource. (You can work around this using a Custom Output Format with basename = "", but that may not work well if you need a dot file containing binary data).
For another example, if you have many resources for a page and want to exclude only one, you must either use the global ignoreFiles, or use publishResources: false and ensure that you use .Permalink or .RelPermalink for all of the others.

What do you think of:

  1. Creating an includeFiles global configuration setting which can be used to override the hard-coded filename filter?
  2. Creating a "publish" resource metadata value that allows publishing to be explicitly enabled or disabled for a resource? This would achieve the same goal as the .hugoignore proposal above, but would allow either setting publishResources: true and explicitly marking resources to be ignored or setting publishResources: false and explicitly marking resources to be published.
1 Like