当前位置: 首页 > 工具软件 > Jekyll > 使用案例 >

Jekyll语法

卓胜
2023-12-01

http://ju.outofmemory.cn/entry/149459  (Jekyll/Liquid API 语法文档)

https://www.jianshu.com/p/9f71e260925d

  • {% for post in paginator.posts %} {% endfor %}表示一个for循环,百分号之间的语句为要执行的语句,该段代码表示分页输出文章,分页数量在_config.yml中配置,注意:分页只在根目录下的index.html中有效

  • { site.自定义字段名称 } 表示获取_config.yml里面的自定义字段名称的值

  • {% for post in site.posts limit:2 %} {% endfor %}循环输出 2 篇文章

  • {% for post in site.posts offset:0 limit:2 %}循环输出最新2篇文章

  • {% for tag in post.tags %} {% endfor %}输出该篇文章里的tag

  • {% if link.type == site.blog_1 %} {% endfor %}字符串比较

  • | {% assign count = 0 %}****{% assign count = count | plus: 1 %}定义assign变量加1 |

  • {{post.content | strip_html | strip_newlines | truncate: 100 }}获取文章摘要,取前100个字符

  • 2018-02-10-你要添加的描述.markdown,文章命名格式,否则识别不了

  • {{ page.date | date: ‘%Y, %b %d’ }}输出文章日期

  • {{page.title}}输出文章标题

  • {% if post.jekyll %} 判断文章里的jekyll字段是否为true

  • {% if paginator.previous_page %}是否有上一页

  • {% if paginator.next_page %}是否有下一页

  • {{ paginator.previous_page_path }}上一页url

  • {{ paginator.next_page_path }}下一页url

  • | {{ post.url | prepend: site.baseurl }}要访问的文章的url |

 类似资料: