Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Excluding subdirectory from being generated #906

Closed
Apathetic012 opened this Issue · 40 comments
@Apathetic012

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

exclude:
  - assets/sass
  - README.md
  - config.rb

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

Directioner forever

@gummesson

Use sass instead of assets/sass. :)

@jwebcat

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

@aahan

@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

@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

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  index.md

./dir1:
index1.md  index2.md

./dir2:
index.md

./dir3:
index.md

./dir4:
index.md
$ cat _config.yml             
safe:        false
auto:        true
server:      true
server_port: 4000
pygments:    true

exclude:
  - dir1/index2.md
  - dir2/
  - dir3
$ jekyll --no-auto --no-server
[...]
$ ls -R _site
_site:
dir1  dir2  dir4  index.html

_site/dir1:
index1.html  index2.html

_site/dir2:
index.html

_site/dir4:
index.html

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

@aahan

@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

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

what-a-page
--index.md
another-page
--index.md

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

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)

:scream_cat:

@Apathetic012

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

@jwebcat

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

@gummesson

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

@Apathetic012

@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

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

@stomar

I think the issue should be kept open.

@Apathetic012 Apathetic012 reopened this
@jwebcat

@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?

@mattr-
Owner

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 README.md in exclude means that any file with the name README.md 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

@mattr- wonderful :+1: I am more than willing to help update the docs.

  • let's all make Jekyll rock!
@stomar

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.

@parkr
Owner

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

@parkr parkr closed this
@jwebcat

@parkr include behaves the same then I imagine right?

@parkr
Owner

I believe so.

@jwebcat

@parkr cool. I will test it.

I Would love your opinion on this rakefile I made for Jekyll https://github.com/jwebcat/rake-jekyll-grunt.git it uses grunt and live reload. My ruby is super basic and I imagine could be improved.

@rebelzach

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

exclude:
  - vendor

Ignores all vendor folders anywhere
Other options I've tried

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

Thoughts?

@jwebcat
@rebelzach

Just tried, no dice.

@jwebcat
@rebelzach

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.

@jwebcat
@stomar

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

@jwebcat
@afeld afeld referenced this issue from a commit in github/choosealicense.com
@afeld afeld ignore test directories from build 804fc48
@dcalhoun dcalhoun referenced this issue in robwierzbowski/generator-jekyllrb
Closed

Placing assets in subdirectories breaks LiveReload #56

@XhmikosR XhmikosR referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@robwierzbowski

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?

@jwebcat
@jwebcat
@maban

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

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

@mscharley
@evert

Thank you, that's good to know!

@ryanburnette

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
exclude:
  - 'src'
  - 'source'
  - 'sass'
@RonJeffries

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/foo.bar, it appears that you cannot exclude just foo.bar.

If you say xyzzy, not xyzzy/, the folder will be excluded and so will any file (and folder?) containing the string 'xyzzy', such as article-about-xyzzy-magic-word.md

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.

@aaronlademann-wf

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

include:
  - "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:

include:
  - "_*"

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.

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.