您的位置:首页 > 其它

jekyll项目开发

2015-10-30 15:42 239 查看
1. jekyll serve

a built-in development server that will allow you to preview what the generated site will look like in your browser locally.

运行此命令,可以在本地预览将要生成的网站的样子。

2. _config.yml

Many configuration options can either be specified as flags on the command line, or alternatively (and more commonly) they can be specified in the _config.yml file at the root of the source directory. Jekyll will automatically use the options from this file
when run.

3. _includes

These are the partials that can be mixed and matched by your layouts and posts to facilitate reuse. 使用方法 {% include file.ext %}

该文件夹下存放可以重复使用的部件。

4.  specify site-wide defaults using the defaults key in the _config.yml

Often times, you will find that you are repeating a lot of configuration options. Setting the same layout in each file, adding the same category - or categories - to a post, etc. You can even add custom variables like author names, which might be the same
for the majority of posts on your blog.

为了避免重复设置,Jekyll提供了一种方法在网站配置里 (_config.yml)设置这些默认设置。关键词 defaults 包含一组 scope/values 对,定义一个指定文件路径下默认设置是什么,作为可选项,可以指定该路径下特定的文件类型。

比如,你希望给你网站上所有页面和文章都使用叫 default 的布局。则添加以下代码:

defaults:
-
scope:
path: "" # an empty string here means all files in the project
type; “posts”
values:
layout: "default"
The different types that are available to you are pages,posts,drafts or any collection in your site (自定义的 collection)

此外,defaults 可以包含多个 scope/values 对。

并且,你可以在具体的 post 或 page 文件里对这些设置重写。

5. _site 此目录下默认用来放置Jekyll生成的网站。最好把此文件夹添加到你的 .gitignore 文件里。运行下面代码。

~/Documents/project-directory$ touch .gitignore

6. 添加 images, fonts 或其他 CSS库

官网上在 structure 这一章节里讲到,除了列举出的默认的文件夹,项目根目录下的所有其他 directory 和 file(如 CSS 和 images 文件夹,favicon.ico 文件,等)都将逐一被直接复制到生成的网站下。所以,如果希望添加web font,如下:

@mixin embed-font($font-name, $font-filename) {
@font-face {
font-family: $font-name;
src: url("../assets/fonts/" + $font-filename + ".ttf") format("truetype");
}
}

@include embed-font("cholla-slab", "ChollaSlabRegular");

$base-font-family: "cholla-slab", serif;

7. When to use a post, a page, or a collection

+-------------------------------------+         +----------------+
| Can the things be logically grouped?|---No--->|    Use pages   |
+-------------------------------------+         +----------------+
|
Yes
|
V
+-------------------------------------+         +----------------+
|      Are they grouped by date?      |---No--->|Use a collection|
+-------------------------------------+         +----------------+
|
Yes
|
V
+-------------------------------------+
|            Use posts                |
+-------------------------------------+
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: