Running Jekyll

Episode #17 - May 11, 2016 - 4 minutes

Subscribe to Jekyll Casts

To run jekyll on a site, we’ll navigate to the site’s directory in the command line, then run one of these commands.

jekyll serve

This builds the site to _site and runs a local development server at http://localhost:4000 by default. Any changes we make to a site (except edits to _config.yml) trigger the site to rebuild and the development server to refresh. This command is typically used while you’re developing a site as it automatically builds and serves your site locally after a change.

jekyll build

This builds the site to _site. From here we would typically copy the contents of _site to a hosting provider.

There’s also a number of runtime flags we can run with these commands to adjust how the site is built. For example if we wanted the build to include all of our draft blog posts we could run jekyll like this.

jekyll build --drafts

Below is a full list of the run time parameters available. Many of these can be added to your _config.yml if you want them to run every time, check the configuration documentation for more information.

Setting Flags

Site Source

Change the directory where Jekyll will read files

-s, --source DIR

Site Destination

Change the directory where Jekyll will write files

-d, --destination DIR

Safe

Disable custom plugins and ignore symbolic links.

--safe

Regeneration

Enable auto-regeneration of the site when files are modified.

-w, --[no-]watch

Configuration

Specify config files instead of using _config.yml automatically. Settings in later files override settings in earlier files.

--config FILE1[,FILE2,...]

Drafts

Process and render draft posts.

--drafts

Environment

Use a specific environment value in the build.

JEKYLL_ENV=production

Future

Publish posts or collection documents with a future date.

--future

LSI

Produce an index for related posts.

--lsi

Limit Posts

Limit the number of posts to parse and publish.

--limit_posts NUM

Force polling

Force watch to use polling.

--force_polling

Verbose output

Print verbose output.

-V, --verbose

Silence Output

Silence the normal output from Jekyll during a build

-q, --quiet

Incremental build

Enable the experimental incremental build feature. Incremental build only re-builds posts and pages that have changed, resulting in significant performance improvements for large sites, but may also break site generation in certain cases.

-I, --incremental

Subscribe to Jekyll Casts