hugopublic-htmlstatic-site-generation

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


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


Solution

  • 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.