Jekyll-Lambda 项目使用教程
1. 项目的目录结构及介绍
Jekyll-Lambda 项目的目录结构如下:
jekyll-lambda/
├── _includes/
├── _layouts/
├── _posts/
├── css/
├── images/
├── .gitignore
├── 404.md
├── Gemfile
├── Gemfile.lock
├── LICENSE
├── README.md
├── Rakefile
├── _config.yml
├── about.md
├── feed.xml
└── index.html
目录介绍:
_includes/
:包含可重用的 HTML 片段。_layouts/
:包含页面布局模板。_posts/
:包含博客文章。css/
:包含样式文件。images/
:包含图片资源。.gitignore
:指定 Git 忽略的文件和目录。404.md
:404 错误页面。Gemfile
:指定项目依赖的 Ruby gems。Gemfile.lock
:锁定 gem 版本。LICENSE
:项目许可证。README.md
:项目说明文档。Rakefile
:包含 Rake 任务。_config.yml
:Jekyll 配置文件。about.md
:关于页面。feed.xml
:RSS 订阅源。index.html
:项目主页。
2. 项目的启动文件介绍
项目的启动文件是 index.html
,它是项目的主页。以下是 index.html
的内容:
---
layout: default
---
<div>
{% assign index = true %}
{% for post in paginator.posts %}
{% assign content = post.content %}
<article>
{% include article.html %}
</article>
{% endfor %}
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path }}" class="previous">Previous</a>
{% else %}
<span class="previous">Previous</span>
{% endif %}
<span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path }}" class="next">Next</a>
{% else %}
<span class="next ">Next</span>
{% endif %}
</div>
</div>
启动文件介绍:
layout: default
:指定使用_layouts/default.html
作为布局模板。{% assign index = true %}
:设置变量index
为true
。{% for post in paginator.posts %}
:遍历分页器中的文章。{% include article.html %}
:包含_includes/article.html
文件。div class="pagination"
:分页导航。
3. 项目的配置文件介绍
项目的配置文件是 _config.yml
,它包含了 Jekyll 站点的配置信息。以下是 _config.yml
的部分内容:
title: Jekyll Lambda
description: An ascetic theme for Jekyll
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
markdown: kramdown
highlighter: rouge
gems:
- jekyll-paginate
paginate: 5
paginate_path: "/page:num/"
permalink: /:year/:month/:day/:title/
exclude:
- Gemfile
- Gemfile.lock
- vendor
- README.md
- Rakefile
配置文件介绍:
title
:站点标题。description
:站点描述。baseurl
:站点的子路径。url
:站点的基本主机名和协议。markdown
:使用的 Markdown 解析器。highlighter
:代码高亮工具。gems
:依赖的 gems。paginate
:每页显示的文章数量。