This article is part of a series of posts about Jekyll from my lynda.com course Jekyll for Web Designers. For a complete list of articles in this series check out the archives.
To control Jekyll you’ll run a series of commands within your command-line interface. The Jekyll gem gives you the
jekyll executable, which has several commands and options you can use to build and serve your site. Let’s explore these commands and their options:
Build does just that; it takes the contents of the current directory and generates it into the destination directory. If that directory is not specified, it defaults to the
_site directory inside the current directory. Both the source and destination directories can be passed as options, just provide the path to the directory after the option.
doctor command checks your site for URL conflicts, errors with your permalinks, and deprecation warnings. This can be especially useful if you’ve moved pages around or reorganized your site.
help command generates a small help document that lists the current version of Jekyll, and reviews available commands and their options.
new command generates a default Jekyll site in the specified directory. This is an extremely useful way to understand how Jekyll works, as you can explore and modify the default site. It’s also a great way to jump-start development, since many of the files and directories you need to create a Jekyll site will be created for you. The
blank option creates a minimal directory structure with no files and an empty index file.
serve command generates the site and launches a built-in development server that allows you to preview your site. In its default option the server watches the source directory. Any changes made to source files will result in the server automatically regenerating those files and updating the site locally. To preview your site browse to http://localhost:4000/ unless you’ve specified a different base URL, in which case you’ll add that to the end of localhost:4000.