Use Jekyll with Gulp

2019-01-21 18:10发布

问题:

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?

回答1:

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'});


回答2:

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.



回答3:

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

Gulp+Jekyll+SASS



回答4:

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.



标签: jekyll gulp