Skip to content

Excluding subdirectory from being generated #906

Apathetic012 opened this Issue Mar 31, 2013 · 41 comments

I wanted to exclude assets/sass from being included into the generated _site:

  - assets/sass
  - config.rb

However it still includes assets/sass. I tried adding a trailing slash, putting it inside quotation marks but none works?

Directioner forever


Use sass instead of assets/sass. :)

jwebcat commented Mar 31, 2013

@Apathetic012 you can also put the directories / files you want to exclude in an array like
[sass,, config.rb]

aahan commented Mar 31, 2013

@Apathetic012 Add this in your config.yml file and see if it does it:

exclude: [assets/sass/]

More info on Jekyll Configuration Settings Wiki

Alternatively, if possible, just add an _ (underscore) to the name of the directories you want to exclude. So, in your case, rename sass to _sass.

jwebcat commented Mar 31, 2013

@aahan I tried that as well. No dice
In the docs it says that adding a trading slash will work with sub dirs
I think we should start an issue.

stomar commented Mar 31, 2013

I had the same problem just a couple of hours ago.

Adding an underscore is no option (e.g. for Gemfile, Capfile, ...)

IMO there are at least two problems with exclude:

1. The behaviour is not documented correctly (or not implemented as intended...):

$ ls -R
_config.yml  dir1  dir2  dir3  dir4




$ cat _config.yml             
safe:        false
auto:        true
server:      true
server_port: 4000
pygments:    true

  - dir1/
  - dir2/
  - dir3
$ jekyll --no-auto --no-server
$ ls -R _site
dir1  dir2  dir4  index.html

index1.html  index2.html



2. It should be possible to specify a full path and exclude only a specific file in a specific directory (exclude: will exclude all files in the complete directory tree).

aahan commented Mar 31, 2013

@jwebcat Well, we already did, didn't we? And I agree with you. I am starting to see a couple of things, not working as described in Jekyll docs (for example).

jwebcat commented Mar 31, 2013

@aahan agreed :) as we would obviously like to have the same name for multiple different locations as with


as @stomar points out this kind of seems like a no-brainer that it should be an option.

Or at the very least we could know how it is done, although I have tried every possibility I could think of with no dice.

stomar commented Mar 31, 2013

I believe the current "options" are:

  • exclude the complete directory (and all other files/directories with the same basename, too)
  • exclude the specific file (and all other files/directories with the same basename, too)



I guess my last resort for now is to prepend an underscore to the directory.

jwebcat commented Mar 31, 2013

@parkr any chance this is coming with the next release?


@Apathetic012, do you use stable or beta? I use the same structure as you, ie: assets/sass, and I can exclude the folder by having exclude: ["sass"] in my config file.


@gummesson my version's Jekyll 0.12.1.

EDIT: I updated to jekyll 1.0.0.beta2 and I do can ignore the folder through it's name. I guess I should close this?

stomar commented Mar 31, 2013

@Apathetic012, as long as you do not have another file/directory sass in the directory tree, exclude: sass should work fine.

stomar commented Mar 31, 2013

I think the issue should be kept open.

@Apathetic012 Apathetic012 reopened this Mar 31, 2013
jwebcat commented Mar 31, 2013

@stomar I agree this seems like a no brainer.

It's almost pointless to attempt a PR as almost all new features are bring shot down by the elders in charge of Jekyll with the excuse that it will make Jekyll too complex.

... it seems like we're in a kind of waiting zone until new features are ok'ed by @mojombo . I know there are a lot of things to take into account with each new feature request.

Other wise I guess we can make a fork that will be more conformist to obvious public needs and features requests, instead of some kind of personal blog project that github happens to be using for hmm pages, and everyone is using and contributing to.

incremental regeneration for example is one thing I flat out need if I see myself using Jekyll much longer.

Anyone... thoughts?

Jekyll member
mattr- commented Apr 1, 2013

I can confirm the following:

  • Using assets/sass as a part of exclude does not work
  • Using assets/sass/ as a part of exclude does not work
  • Using sass/ as part of exclude does not work
  • Using sass as a part of exclude does work
  • Having in exclude means that any file with the name anywhere within the site's files and subdirectories will be excluded from the generated site.
  • The current functionality seems to be in place since at least v0.10 (that's as far back as I went), which is two years. I suspect it's been this way even longer.

We intend to update the documentation before 1.0.0 is released. If you'd like to accelerate the release and reduce your frustration, I highly suggest helping out to make the docs match what is implemented. The help would be gladly welcome. You may also submit a pull request for the particular behavior you want and we can discuss what the desired functionality should be. In the meantime, I've adjusted the wiki page to remove the comment about the trailing slash, since it doesn't apply

jwebcat commented Apr 1, 2013

@mattr- wonderful 👍 I am more than willing to help update the docs.

  • let's all make Jekyll rock!
stomar commented Apr 1, 2013

I'm just guessing but the behavior of include is probably similar and would have to be considered also for future feature or pull requests.

The documentation is not clear about the precedence of exclude and include.

Jekyll member
parkr commented Apr 1, 2013

1.0 betas support glob exclusion. assets/sass/**/* should work.

@parkr parkr closed this Apr 1, 2013
jwebcat commented Apr 1, 2013

@parkr include behaves the same then I imagine right?

Jekyll member
parkr commented Apr 1, 2013

I believe so.

jwebcat commented Apr 1, 2013

@parkr cool. I will test it.

I Would love your opinion on this rakefile I made for Jekyll it uses grunt and live reload. My ruby is super basic and I imagine could be improved.


Any thoughts on how I should exclude only a root directory or file.
From the source Jekyll directory I want to ignore ./vendor

  - vendor

Ignores all vendor folders anywhere
Other options I've tried

- /vendor
- /vendor/
- ./vendor/



Just tried, no dice.


Yeah that solves my problem, but I thought I would bring up that this type of matching doesn't work. I would have expected it to work much like gitignore. For now I'll use underscores.

stomar commented Sep 16, 2013

As I already stated 6 months ago, I still think there should be a way to exclude /vendor but not /some_dir/vendor.

@afeld afeld referenced this issue in github/ Dec 12, 2013
@afeld afeld ignore test directories from build 804fc48
@dcalhoun dcalhoun referenced this issue in robwierzbowski/generator-jekyllrb Dec 20, 2013

Placing assets in subdirectories breaks LiveReload #56


Glob ignores don't seem to work in 1.3.1. With the directory assets/js,

assets/js doesn't exclude
assets/js/**/* doesn't exclude
js excludes, but of course excludes all other js directories too.

Any other workarounds / fixes for nested excluded directories?

maban commented Jan 2, 2014

In case this helps anyone else, I was having trouble getting Jekyll to exclude Grunt generated files and directories without an underscore. I thought there was something wrong with my syntax, but when I restarted Terminal after editing the config file, it finally worked. Here's what my exclude looks like:

exclude: [node_modules, package.json, npm-debug.log, Gruntfile.js, scss]
evert commented Apr 15, 2014

bit surprised that this is still an issue after a year.

evert commented Apr 15, 2014

Thank you, that's good to know!


I format my excludes this way. Doesn't matter as long as it's yaml. The behavior is the same. I use a few keywords to ignore directories because Jekyll doesn't support glob in excludes. It'll be cool when 2.x comes out and adds that though.

# _config.yml
  - 'src'
  - 'source'
  - 'sass'

Hello. I am from the future, specifically February 2015. This issue is still not resolved. It is possible to exclude a folder by putting its exact name in the exclude. If the folder's name is, say, xyzzy, you can put
xyzzy, or xyzzy/ and the folder will be excluded.

If you say xyzzy/, it appears that you cannot exclude just

If you say xyzzy, not xyzzy/, the folder will be excluded and so will any file (and folder?) containing the string 'xyzzy', such as

File watch does not interpret the things in exclude the same way that jekyll generation does. It is possible to set things up so that watch will not trigger but jekyll will generate the file if started manually. I believe it is possible to do the reverse.

There are essentially zero working examples anywhere. I would wager that there are no working tests or checks as well, since if there were someone would surely have published them by now.

This is not the end of the world. I'll write to you about that later. But it is not particularly good nor impressive.


+1 to what @RonJeffries said... this issue seems to have re-appeared.

I have been using the following include configuration for the past 6 months to ensure that the entire contents of my sass directory are copied for purposes of source mapping... It was working until a few days ago.

  - "sass/_*"

The only way I can get the underscored files / directories in my sass directory to be copied during build - is by changing my include to:

  - "_*"

This is sub-optimal, however, because it now copies the entirety of _includes, _layouts, _data, etc.

@parkr @mojombo should a new issue be opened - or is this issue still an appropriate place to investigate possible regressions?

Using jekyll 2.4.0

Thanks for your time.

nhoizey commented Aug 28, 2015

I am strugling with this as well, with Jekyll 2.5.3.

I have a tags folder in the root, and I want its content to be added to the _site/tags/ folder that is generated by the jekyll tagging plugin.

I tried several syntaxes, from the comments in this thread, with no result.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.