本文介绍了尽管使用_config.yml,Jekyll在_site中打开了目录。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在与Jekyll建立一个网站,并使用Gulp来管理资产。由于我使用Gulp来管理我的资产,因此我希望Jekyll在转换过程中忽略./assets,并在构建网站的其他部分时单独离开./_site/assets/。 我已经使用 exclude配置了_config.yml:[assets]#排除assets / from转换保留:[assets]#在构建站点时不要删除_site / assets 我的gulpfile.js是: var gulp = require('gulp'); var sass = require('gulp-ruby-sass'); gulp.task('sass',function(){ return sass('assets / stylesheets / main.scss') .on('error',sass。 logError) .pipe(gulp.dest('_ site / assets /')); }); gulp.task('default',function(){ gulp.start('sass'); }); 然后运行: gulp jekyll build 当我运行 gulp ,./_sites/assets/目录是按预期创建的,但是当我运行 jekyll build ./_site/assets/时删除。我缺少什么配置?解决方案正如前面提到的keep_files指令是正确的,而不是保留。以下来自Jekyll网站的信息 http://jekyllrb.com/docs/configuration/ 我决定检查这个通过从头开始做事部分,我追加到默认jekyll的_config.yml文件看起来像这样 排除:[someFolderHere] keep_files:[someFolderHere] wolf @ sloth:〜/ blogs $ jekyll新的虚拟博客安装了新的jekyll站点in / home / wolf / blogs / dummy-blog。 wolf @ sloth:〜/ blogs $ cd dummy-blog / wolf @ sloth:〜/ blogs / dummy-blog $ wolf @ sloth:〜/ blogs / dummy-blog $ ll -rta 总计40 drwxr-xr-x 12狼狼4096 Jan 30 09:40 .. -rw-r - r-- 1狼狼435 Jan 30 09:40 _config.yml drwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 _layouts -rw-r - r-- 1狼狼451 Jan 30 09:40 index .html drwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 _includes drwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 css drwxr-xr-x 2狼狼4096 Jan 30 09:40 _posts -rw-r - r--狼狼192 12年1月30日09:40 feed.xml -rw-r - r--狼狼470 1月30日09:40 about.md drwxr-xr-x 6狼狼4096 Jan 30 09:40。 wolf @ sloth:〜/ blogs / dummy-blog wolf @ sloth:〜/ blogs / dummy-blog $ jekyll建立配置文件:/home/wolf/blogs/dummy-blog/_config.yml 来源:/ home / wolf / blogs / dummy-blog 目的地:/ home / wolf / blogs / dummy-blog / _site 正在生成... 完成。 wolf @ sloth:〜/ blogs / dummy-blog wolf @ sloth:〜/ blogs / dummy-博客$ ll -rta 总计44 drwxr-xr-x 12狼狼4096 Jan 30 09:40 .. -rw-r - r-- 1狼狼435 1月30日09:40 _config.yml drwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 _layouts -rw-r - r-- 1 wolf wolf 451 Jan 30 09:40 index.html drwxr-xr-x 2狼狼4096 Jan 30 09:40 _includes drwxr-xr-x 2狼狼4096 Jan 30 09:40 css drwxr-xr-x 2狼狼4096 Jan 30 09:40 _posts -rw-r - r-- 1 wolf wolf 1292 Jan 30 09:40 feed.xml -rw-r - r-- 1狼狼470 1月30 09:40 about.md drwxr-xr-x 5狼狼4096 Jan 30 09:41 _site drwxr-xr-x 7狼狼4096 Jan 30 09:41。 wolf @ sloth:〜/ blogs / dummy-blog $ ll _site / 共32 drwxr- xr-x 3 wolf wolf 4096 Jan 30 09:41 jekyll -rw-r - r-- 1 wolf wolf 5816 Jan 30 09:41 index.html -rw-r - r- - 1 wolf wolf 2954 Jan 30 09:41 feed.xml drwxr-xr-x 2狼狼4096 Jan 30 09:41 css drwxr-xr-x 2狼狼4096 Jan 30 09:41约 drwxr-xr-x 7狼狼4096 Jan 30 09:41 .. drwxr-xr-x 5狼狼4096 Jan 30 09:41。 wolf @ sloth:〜/ blogs / dummy-blog wolf @ sloth:〜/ blogs / dummy-blog $ mkdir _site / someFolderHere wolf @ sloth:〜/ blogs / dummy-blog $ touch _site / someFolderHere / toasttoast123 wolf @ sloth:〜/ blogs / dummy-blog $ wolf @ sloth:〜/ blogs / dummy-blog $ jekyll build 配置文件:/home/wolf/blogs/dummy-blog/_config.yml 来源:/ home / wolf / blogs / dummy-blog 目的地:/ home / wolf / blogs / dummy-blog / _site 正在生成... 完成。 wolf @ sloth:〜/ blogs / dummy-blog wolf @ sloth:〜/ blogs / dummy -blog $ ll _site / someFolderHere / toasttoast123 ls:无法访问_site / someFolderHere / toasttoast123:没有这样的文件或目录 wolf @ sloth:〜/ blogs / dummy-blog $ code> wolf @ sloth:〜/ blogs / dummy-blog $ wolf @ sloth:〜/ blogs / dummy-blog $ cp - p _config.yml _config.yml.somebackup wolf @ sloth:〜/ blogs / dummy-blog $ rvim _config.yml wolf @ sloth:〜/ blogs / dummy-blog $ diff -u _config.yml _config.yml.somebackup --- _config.yml 2016-01-30 09:44: 26.238366056 +0200 +++ _config.yml.somebackup 2016-01-30 09:40:08.422370474 +0200 @@ -10,6 +10,3 @@ #构建设置 markdown:kramdown permalink:pretty - -exclude:[someFolderHere] -keep_files:[someFolderHere] wolf @ sloth:〜/ blogs / dummy- blog $ wolf @ sloth:〜/ blogs / dummy-blog $ mkdir _site / someFolderHere wolf @ sloth :〜/ blogs / dummy-blog $ touch _site / someFolderHere / toasttoast123 wolf @ sloth:〜/ blogs / dummy-blog $ jekyll build 配置文件:/home/wolf/blogs/dummy-blog/_config.yml 来源:/ home / wolf / blogs / dummy-blog 目的地:/ home / wolf / blogs / dummy -blog / _site 正在生成... 完成。 wolf @ sloth:〜/ blogs / dummy-blog wolf @ sloth:〜/ blogs / dummy- blog $ ll _site / someFolderHere / toasttoast123 -rw-r - r-- 1 wolf wolf 0 Jan 30 09:45 _site / someFolderHere / toasttoast123 wolf @ sloth:〜/ blogs / dummy-blog wolf @ sloth:〜/ blogs / dummy-blog $ I'm building a site with Jekyll and using Gulp to manage the assets. Since I'm using Gulp to manage my assets, I would like Jekyll to ignore ./assets in the conversion process and to leave ./_site/assets/ alone when building the rest of the site.I've configured the _config.yml withexclude: [assets] # Exclude assets/ from the conversionkeep: [assets] # Don't delete _site/assets when building the siteMy gulpfile.js is:var gulp = require('gulp');var sass = require('gulp-ruby-sass');gulp.task('sass', function() { return sass('assets/stylesheets/main.scss') .on('error', sass.logError) .pipe(gulp.dest('_site/assets/'));});gulp.task('default', function() { gulp.start('sass');});I then run:gulpjekyll buildWhen I run gulp, the ./_sites/assets/ directory is created as expected, but when I run jekyll build ./_site/assets/ is deleted. What configuration am I missing? 解决方案 As was noted before keep_files directive is correct, instead of just keep. Following information from Jekyll's site http://jekyllrb.com/docs/configuration/ I decided to check this by doing things from scratch step by step part that I appended to default jekyll's _config.yml file looks like thisexclude: [someFolderHere] keep_files: [someFolderHere]wolf@sloth:~/blogs$ jekyll new dummy-blog New jekyll site installed in /home/wolf/blogs/dummy-blog. wolf@sloth:~/blogs$ cd dummy-blog/ wolf@sloth:~/blogs/dummy-blog$ wolf@sloth:~/blogs/dummy-blog$ ll -rtatotal 40drwxr-xr-x 12 wolf wolf 4096 Jan 30 09:40 ..-rw-r--r-- 1 wolf wolf 435 Jan 30 09:40 _config.ymldrwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 _layouts-rw-r--r-- 1 wolf wolf 451 Jan 30 09:40 index.htmldrwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 _includesdrwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 cssdrwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 _posts-rw-r--r-- 1 wolf wolf 1292 Jan 30 09:40 feed.xml-rw-r--r-- 1 wolf wolf 470 Jan 30 09:40 about.mddrwxr-xr-x 6 wolf wolf 4096 Jan 30 09:40 .wolf@sloth:~/blogs/dummy-blog$wolf@sloth:~/blogs/dummy-blog$ jekyll buildConfiguration file: /home/wolf/blogs/dummy-blog/_config.yml Source: /home/wolf/blogs/dummy-blog Destination: /home/wolf/blogs/dummy-blog/_site Generating... done.wolf@sloth:~/blogs/dummy-blog$wolf@sloth:~/blogs/dummy-blog$ ll -rtatotal 44drwxr-xr-x 12 wolf wolf 4096 Jan 30 09:40 ..-rw-r--r-- 1 wolf wolf 435 Jan 30 09:40 _config.ymldrwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 _layouts-rw-r--r-- 1 wolf wolf 451 Jan 30 09:40 index.htmldrwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 _includesdrwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 cssdrwxr-xr-x 2 wolf wolf 4096 Jan 30 09:40 _posts-rw-r--r-- 1 wolf wolf 1292 Jan 30 09:40 feed.xml-rw-r--r-- 1 wolf wolf 470 Jan 30 09:40 about.mddrwxr-xr-x 5 wolf wolf 4096 Jan 30 09:41 _sitedrwxr-xr-x 7 wolf wolf 4096 Jan 30 09:41 .wolf@sloth:~/blogs/dummy-blog$ ll _site/total 32drwxr-xr-x 3 wolf wolf 4096 Jan 30 09:41 jekyll-rw-r--r-- 1 wolf wolf 5816 Jan 30 09:41 index.html-rw-r--r-- 1 wolf wolf 2954 Jan 30 09:41 feed.xmldrwxr-xr-x 2 wolf wolf 4096 Jan 30 09:41 cssdrwxr-xr-x 2 wolf wolf 4096 Jan 30 09:41 aboutdrwxr-xr-x 7 wolf wolf 4096 Jan 30 09:41 ..drwxr-xr-x 5 wolf wolf 4096 Jan 30 09:41 .wolf@sloth:~/blogs/dummy-blog$ wolf@sloth:~/blogs/dummy-blog$ mkdir _site/someFolderHerewolf@sloth:~/blogs/dummy-blog$ touch _site/someFolderHere/toasttoast123wolf@sloth:~/blogs/dummy-blog$wolf@sloth:~/blogs/dummy-blog$ ll _site/someFolderHere/toasttoast123 -rw-r--r-- 1 wolf wolf 0 Jan 30 09:42 _site/someFolderHere/toasttoast123wolf@sloth:~/blogs/dummy-blog$ wolf@sloth:~/blogs/dummy-blog$ jekyll buildConfiguration file: /home/wolf/blogs/dummy-blog/_config.yml Source: /home/wolf/blogs/dummy-blog Destination: /home/wolf/blogs/dummy-blog/_site Generating... done.wolf@sloth:~/blogs/dummy-blog$wolf@sloth:~/blogs/dummy-blog$ ll _site/someFolderHere/toasttoast123 ls: cannot access _site/someFolderHere/toasttoast123: No such file or directorywolf@sloth:~/blogs/dummy-blog$ wolf@sloth:~/blogs/dummy-blog$ wolf@sloth:~/blogs/dummy-blog$ cp -p _config.yml _config.yml.somebackupwolf@sloth:~/blogs/dummy-blog$ rvim _config.ymlwolf@sloth:~/blogs/dummy-blog$ diff -u _config.yml _config.yml.somebackup --- _config.yml 2016-01-30 09:44:26.238366056 +0200+++ _config.yml.somebackup 2016-01-30 09:40:08.422370474 +0200@@ -10,6 +10,3 @@ # Build settings markdown: kramdown permalink: pretty--exclude: [someFolderHere]-keep_files: [someFolderHere] wolf@sloth:~/blogs/dummy-blog$ wolf@sloth:~/blogs/dummy-blog$ mkdir _site/someFolderHerewolf@sloth:~/blogs/dummy-blog$ touch _site/someFolderHere/toasttoast123wolf@sloth:~/blogs/dummy-blog$ jekyll buildConfiguration file: /home/wolf/blogs/dummy-blog/_config.yml Source: /home/wolf/blogs/dummy-blog Destination: /home/wolf/blogs/dummy-blog/_site Generating... done.wolf@sloth:~/blogs/dummy-blog$wolf@sloth:~/blogs/dummy-blog$ ll _site/someFolderHere/toasttoast123 -rw-r--r-- 1 wolf wolf 0 Jan 30 09:45 _site/someFolderHere/toasttoast123wolf@sloth:~/blogs/dummy-blog$ wolf@sloth:~/blogs/dummy-blog$ 这篇关于尽管使用_config.yml,Jekyll在_site中打开了目录。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-23 18:36