12

I read about Gulp and was quite taken by the philosophy. I want to try it out for myself but I am running into a little problem. I am used to using Jekyll with Grunt and I have no idea how to get Jekyll to play nice with Gulp.

I've come across this article which suggests there is no need for a Jekyll plugin when using Gulp. Unfortunately it doesn't really explain how to go about it and the example it links to doesn't help me much.

Is there anyone who knows how to go about this?

Thijs
  • 2,341
  • 2
  • 14
  • 22
  • 2
    for clarification, what does "play well" mean? gulp-jekypll will allow you to build. are you looking for a gulp module that will allow you to run a server? – chantastic Jan 22 '14 at 23:16
  • @chantastic I am looking for a way to have Jekyll as my static site generator, have it watch for changes to the source files and recompile and have its output available on a local server. I will have to look at the gulp-jekyll plug-in but from your comment it sounds like it just takes care of the building part. – Thijs Jan 23 '14 at 10:52
  • as far as I know the tooling is not there yet for gulp. If I sent you an answer with a Rake or Grunt solution, would that be appropriate? – chantastic Jan 23 '14 at 17:01
  • @chantastic, I have a Grunt setup which works well for me so there is no need to provide an answer for that. I am not familiar with Rake so I am not sure how useful it would be for me. Thanks anyway! – Thijs Jan 29 '14 at 12:48

4 Answers4

32

Read this blog post: Why you shouldn’t create a gulp plugin

Then realize you can easily trigger Jekyll in vanilla Node.js. No need for a plugin.

require('child_process').spawn('jekyll', ['build'], {stdio: 'inherit'});
Sindre Sorhus
  • 62,972
  • 39
  • 168
  • 232
  • 1
    Here's the docs about `child_process` `spawn`, in case they help anybody understand this answer (it helped me): http://nodejs.org/api/child_process.html#child_process_child_process_spawn_command_args_options – davidtheclark Jul 23 '14 at 02:05
2

Being late to the party, I'd like to ask:
Why you want to combine Jekyll with Gulp?

Jekyll already has some built in tasks, compiling SCSS to CSS for example. And Jekyll itself can also be extended with plugins, for things like minifying and prefixing. So: You might not need to combine two different technologies here at all.

One reason might be, that you want to publish to GitHub pages (extra plugins not supported). So that asset pipelining and Jekyll built will have to become two separated steps. In my case, I was already using auto-prefixer and I didn't wanted to go back to use mixins for that.

While researching and testing this, I found different methods for a Jekyll+Gulp-workflow:

  1. Spawn Jekyll as a child process, most popular, as described by Sindre, here
  2. Run Jekyll serve and Gulp in parallel, there is no need to integrate one into the other, you can also have them running side by side to develop
  3. Call Jekyll from Gulp via a shell command, .pipe(run('bundle exec jekyll build'); Source.

Most people are using Browsersync to serve the site locally then, instead of the builtin jekyll serve method.

Frank Lämmer
  • 2,165
  • 19
  • 26
1

If you want to see what a Jekyll gulp plugin might look like, check out gulp-jekyll. Please comment if you think this project is more or less useful than spawning the process yourself.

RobW
  • 10,184
  • 4
  • 41
  • 40
0

I just tried this YO generator and is working great: https://www.npmjs.org/package/generator-jekyllized

Gulp+Jekyll+SASS