How can I exclude an image from Hugo's public directory?

529 Views Asked by At

I'm using Hugo to generate a static site. I'm making use of Hugo's image functions to create different sized versions of the same image (160px, 240px, and 480px).

That's all working fine but Hugo also makes the original image available (e.g. IMG_7307.jpeg) in the public directory too. I don't want to publish the original images. How can I tell Hugo not to include them?

part of Hugo's public directory structure

1

There are 1 best solutions below

0
Rogelio On BEST ANSWER

You should use Hugo's Build Resources options in your page's front matter. See below for an example:

---
title: Your Page's Title
_build:
  publishResources: false
---

Hello, world!

Any resources in this page's bundle will not be copied into the /public directory unless their .Permalink or .RelPermalink is used.