Exclude files when building the site for upload

Hi,

I’m wondering if there’s a way to exclude some files when bulding the site for upload by running

$ hugo --destination "/tmp/hugo_public" --cleanDestinationDir

In some page bundles, I have some data-files (JSON or CSV) that are needed to create the page, but shouldn’t be on the server.
Right now, I’m excluding them using a rsync-flag while uploading.

I tried using the mount option in my “hugo.toml”,

[module]
[[module.mounts]]
source = 'content'
target = 'content'
excludeFiles = ["**/*.json"]

but then the

.Page.Resources.Match “_data/*.json” 

used in the page doesn’t find them anymore, too.

Is there a way or is using the rsync-flag the best option?

Other than the JSON/CSV files, are there any other page resources within the bundles (e.g., images, videos, etc.)?

Yes, there are - located in the same folder as the “index.md” - while the JSON/CSV-files are always located in the “_data”-subfolder within the bundle.

Since the build options publishresources parameter does not provide a file filter, I think you need to handle this post-build.

Thanks for the quick answer, then I keep excluding them while uploading.

Are the other files in the bundle referenced in Markdown? For example, if the other files in the bundle are images, do you reference every image in Markdown?

No, they aren’t. They are invoked with a custom shortcode.

Does the custom shortcode capture the page resource then call Permalink, RelPermalink, or Publish to publish it?

To display the image .RelPermalink is used.

OK, then you can use build options. See the second list item:

Thanks again - I check if I use something that’s not linked with any of the methods mentioned above and give it a try!