Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Destination as sub-directory causes infinite loop on auto-regeneration #1184

iamdarrenhall opened this Issue · 10 comments

5 participants



I'm having trouble setting the destination to a subdirectory, and running with auto-generation enabled.

jekyll serve --watch --port 8080

It works until I save a file that I've edited, when it regenerates the saved file which then triggers the entire site to update ad infinitum. My _config.yml looks like this:

source: ./
destination: _app/_site
exclude: ['_app']

Is there something I'm missing here with the config, or is this a bug? Cheers!




Bollocks. We fixed the problem produced by specifying a dir other than _site in the root ($CWD) but this was a case it doesn't cover. Thanks!


This is tricky. When determining the globs to watch, it:

1. Fetches all the dirs in the source

>> Dir["*"].select { |x| }
=> ["_app", "_layouts", "_posts", "_site", "css", "images"]

2.Filters out several variations of destination

>> dirs -= [destination] # -= ["./_app/_site"]
=> ["_app", "_layouts", "_posts", "_site", "css", "images"]
>> dirs -= [File.expand_path(destination)] # -= ["/Users/parker/code/jekyll/tsite/_app/_site"]
=> ["_app", "_layouts", "_posts", "css", "images"]
>> dirs -= [File.basename(destination)] # -= ["_site"]
=> ["_app", "_layouts", "_posts", "css", "images"]

3. Maps to globs

>> dirs = { |x| "#{x}/**/*" }
=> ["_app/**/*", "_layouts/**/*", "_posts/**/*", "css/**/*", "images/**/*"]

You can tell that in 2 it isn't filtering that stuff out properly.

@mattr- I think we need to flesh out _app/**/* into sub-globs and exclude the dir in which the destination lies.


I agree.


I see that my issue #1870 duplicates this one. But I pointed out the exact reason of the infinite loop on auto-regeneration.


Yeah, @vonavi is correct. Essentially there are a few cases that allow watch regeneration to work and some that don't.


  • Have no destination: value in _config.yml (uses the default absolute URL of _site inside the directory)
  • destination: /Users/ryanseys/mysite/_site in config.yml (using an absolute URL, even inside the directory)
  • destination: ../_site in config.yml (using an relative URL that is strictly outside the repo)

Does not work:

  • destination: _site in config.yml (using any relative URL inside the main directory) [this is effectively the same as the default config, but there's a bug specified by #1870 that addresses why this doesn't work]

Hope this helps users encountering this bug to implement a workaround depending on whether they want their build inside the main directory or not. I'm not knowledgeable enough with the code to implement a fix but @vonavi + #1870 should be a good start for someone who can! :smile:

Edit: Sorry, web dev here. When I say "URL" I mean the directory names.


So basically, how to fix: Convert all destination names in config file into absolute destinations, even if specified as relative ones. File.expand_path might be a good start.


I use the following lines in _config.yml as a temporary workaround for the issue:

source:      ./
destination: ./public

Interesting tactic! Didn't think of that! :dancer:

@parkr parkr modified the milestone: 2.1, 2.0

Does #2459 solve this?

@parkr parkr modified the milestone: 2.2, 2.1
@parkr parkr referenced this issue in jekyll/jekyll-watch

Ensure Ignores Dest Dir #4


We've released 2.2 and this still sucks. Moving over to jekyll-watch repo.

@parkr parkr closed this
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.