Skip to content

Instantly share code, notes, and snippets.

@dannygarcia
Created September 20, 2012 02:39
Show Gist options
  • Save dannygarcia/3753650 to your computer and use it in GitHub Desktop.
Save dannygarcia/3753650 to your computer and use it in GitHub Desktop.
Sample grunt-jekyll grunt.js

Sample grunt-jekyll grunt.js

  1. Use the following folder structure
[root]
    |-- templates/
        |-- index.html (Jekyll templates)
    |-- prod/
    |-- dev/
    |-- _config.yml (optional)
  1. Add the grunt.js file below at the root of your project.

  2. Install the grunt-jekyll gruntmodule next to your project's grunt.js gruntfile with: npm install grunt-jekyll.

  3. Run the grunt jekyll commands:

  • grunt jekyll or grunt jekyll:server to start a server that watches the templates directory.

  • grunt jekyll:dev to process files to the dev directory.

  • grunt jekyll:prod to process files to the prod directory.

Of course, everything here is fully configurable to your liking.

// Sample grunt-jekyll grunt.js file
// https://github.com/dannygarcia/grunt-jekyll
/*global module:false*/
module.exports = function(grunt) {
// Project configuration.
grunt.initConfig({
jekyll: {
server : {
src : 'templates',
dest: 'dev',
server : true,
server_port : 8000,
auto : true
},
dev: {
src: 'templates',
dest: 'dev'
},
prod: {
src: 'templates',
dest: 'prod'
}
},
watch: { // for development run 'grunt watch'
jekyll: {
files: ['templates/*.html'],
tasks: ['jekyll:dev']
}
}
});
// Default task. Run standard jekyll server.
grunt.registerTask('default', 'jekyll:server');
// plugin tasks
grunt.loadNpmTasks('grunt-jekyll');
};
@ezze
Copy link

ezze commented Oct 28, 2014

I was unable to run a server with Jekyll 2.4.0 and plugin version 0.4.2 on Ubuntu 14.04 LTS. After looking at the source code of the Grunt task I got that it must be serve option instead of server.

server: {
    options: {
        serve: true,
        port: 8000,
        auto: true
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment