A Rakefile to simplify previewing and deploying jekyll websites. The latest version supports Jekyll 1.0.0.
1. Download this repository
2. Put the files in your jekyll installation
3. Set the variables in _rake_configuration.yml
4. Start using it!
Note. I use two separate files to keep the Rakefile
independent of the configuration; it helps when you are managing more than one website with jekyll. However, if you prefer, you can forget about the _rake_configuration.yml
file and set the variables directly in the Rakefile
.
- Ready made tasks for common operations (e.g. creating a post, checking links).
- Optional automatic update of
_config.yml
so thatsite.url
matches the correct URL for deployment and preview.
Some more details about the management of url
in _config.yml
. Sometime it is difficult to use relative URLs in your Jekyll files. Think, e.g., a reference to css files in a layout file which is used for pages living at different levels of nesting.
To avoid the problem, one solution is using the variable {{site.url}}
for the links in your pages. This variable has whatever value you give to the url
directive in _config.yml
. By prepending {{site.url}}
to the relevant links, all URLs can be made absolute and are guaranteed to work, no matter where your HTML file will live.
However, using {{site.url}}
can break the possibility of locally previewing your website with the jekyll serve
command. In fact, the URLs generated will still use the value of {{site.url}}
and point to the wrong files, namely those on the server, rather than those modified locally.
The rakefile can help to automatically switch the value of the url
variable in the _config.yml
file. In particular, if you set the $deploy_url
variable in the Rakefile (deploy
, preview
, build_static
, and build
) will modify the value of the url
directive in _config.yml
. The variable will be set to localhost:4000
when previewing and to $deploy_url
when deploying.
This behavior can be disabled. If you do not want the Rakefile to modify _config.yml
leave the variable $deploy_url
undefined.
rake preview rake deploy
The commands made available are:
rake build # Build for deployment (but do not deploy) rake build_static # Static build (build using filesystem) rake check_links # Check links for site already running on localhost:4000 rake clean # Clean up generated site rake create_post[post,date,content] # Create a post rake deploy # Build and deploy to remote server rake post_changes # Create a post with all changes since last deploy rake preview # Preview on local machine (server with --auto)
If you do not put the following directive in your _config.yml
file:
exclude: ['Rakefile']
the Rakefile
will end up in your website. (It shouldn’t do any harm if you publish it.)
Distributed under the terms of the MIT License