Giter Club home page Giter Club logo

jekyll-rakefile's Introduction

What it is

A Rakefile to simplify previewing and deploying jekyll websites. The latest version supports Jekyll 1.0.0.

Installation

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.

Main Advantages

  • Ready made tasks for common operations (e.g. creating a post, checking links).
  • Optional automatic update of _config.yml so that site.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.

Typical Usage Scenario

rake preview
rake deploy

Commands

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)

Caveats

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.)

License

Distributed under the terms of the MIT License

jekyll-rakefile's People

Contributors

getfol avatar

Watchers

Hou GuoChen avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.