Build a subdirectory
This page applies both for build and serve commands.
The default source for Jekyll is the current directory. But you might have put your Jekyll project in a subdirectory, such as docs. Here is how to do that.
Navigate approach
The simplest is to navigate there first.
$ cd docs
$ bundle exec jekyll build
This assumes you have a structure like this:
docs/_site/vendor/_config.ymlGemfileindex.md
You can change the output directory.
$ cd docs
$ bundle exec jekyll build -d ../build
This will result in the following:
build/- in place of_site.docs/vendor/_config.ymlGemfileindex.md
Build subdirectory from root approach
If you prefer, you can stay at the root and build a subdirectory.
This is probably not a good idea if you have a subdirectory like docs, typically you’ll want all Jekyll-related files together the and isolated from other code in the root.
Here we use the --source and --destination flags.
$ bundle exec jekyll build -s docs -d build
This assumes you have a structure like this:
build/- in place of_site.docs/_config.ymlindex.md
vendor/Gemfile
As another use case, perhaps you have multiple Jekyll sites in your repo and they all share gems at the top-level.