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.

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.yml
    • Gemfile
    • index.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.yml
    • Gemfile
    • index.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.yml
    • index.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.