Building WITH files, but no putting those files in the build? ignoreFiles doesn't seem to do the trick

I’m using css files in each content folder to insert styles in the head of pages, working as desired here:

{{- if .Params.custom_css }}
    <style>{{ (.Resources.GetMatch "index.css").Content | safeCSS }}</style>
    {{- end }}

I don’t want these files to be transferred over during builds, since they are not linked/used by any page. I thought initially ignoreFiles would do the trick, but it seems to exclude the file FROM the build. So, this setting:

ignoreFiles = [“index.css$”]

Triggers the following error:

Error: Error building site: failed to render pages: render of “home” failed: execute of template failed: template: index.html:3:7: executing “index.html” at <partial “head.html” .>: error calling partial: “C:\Hugo\Sites\powerspreaders\themes\twstarter\layouts\partials\head.html:27:35”: execute of template failed: template: partials/head.html:27:35: executing “partials/head.html” at <“index.css”>: nil pointer evaluating resource.Resource.Content

It seems ignoreFiles does just that, it doesn’t allow the build to use the index.css files. I want the build to use the files BUT not transfer them over to the build. Is that possible?

Have a look at the Build Options

You most likely need to set publishResources to false.

Yep, that was it. Setting the following in the page params worked.

title: My Page
linktitle: Home
custom_css: true
  publishResources: false


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