How to exclude a directory but not all of its contents?

#1

I want to all files in directories with a name like this /assets/blog/[post date]/ to be excluded from the build, but not any files in such a directory’s sub directories. Is that possible?

Background: my images are organized with this directory structure:
/assets/blog/[post date]/

I’m using the Jekyll Picture Tag plugin to automatically create responsive images. Because the plugin creates resized copies in another directory, I don’t need the original images. So I’ve added the following to exclude in _config.yml:
"/assets/blog/*.jpg", "/assets/blog/*.png"

The problem is that I’d like to store Open Graph and Twitter card images in the same directory (or a sub directory) for each post. I considered putting those in a sub directory and tried using regex in the exclude property to only include in a sub directory of each posts’ assets directory, but that didn’t work. This is the regex I used:
"/assets/blog/????-??-??/[\w|-]+.png"

0 Likes

#2

I no longer have the need for an answer, as I found out that Jekyll Picture Tag can also render image URIs without the html tags around them. That allows me to have the OG and Twitter card images parsed by the plugin. Now I can just exclude all images in the /assets/blog/ directory.

0 Likes