我想用Jekyll创建一个网站.不是博客.有没有办法避免在网址和网页文件名中指定创建日期?
我认为Jekyll背后的想法非常棒,但它似乎与博客生成内容有关,而在更一般的用例中也可能有用.
jos*_*y10 49
在_config文件中,您可以将固定链接更改为您喜欢的任何内容,例如我的
permalink: /blog/:title
Run Code Online (Sandbox Code Playgroud)
至于日期,你可以使用YAML前面的事情选择你自己的日期,再次在我的
title: example
date: you can pick what ever date you want
Run Code Online (Sandbox Code Playgroud)
Joo*_*stS 11
什么文档说:
您可以像这样在 _config.yml 文件中配置永久链接:
Run Code Online (Sandbox Code Playgroud)permalink: /:categories/:year/:month/:day/:title.html如果您没有指定任何永久链接设置,Jekyll 将使用上述模式作为默认模式。也可以使用内置的永久链接样式设置永久链接:
Run Code Online (Sandbox Code Playgroud)permalink: date尽管您可以使用模板变量指定自定义永久链接模式,但为了方便起见,Jekyll 还提供了以下内置样式。
- 日期 = /:categories/:year/:month/:day/:title.html
- 漂亮 = /:categories/:year/:month/:day/:title/
- 序号 = /:categories/:year/:y_day/:title.html
- none = /:categories/:title.html
来源:https : //jekyllrb.com/docs/permalinks/
这是我使用的基本设置:
permalink: pretty
Run Code Online (Sandbox Code Playgroud)
这将页面设置为漂亮的永久链接样式。因此'/contact.md' 将变成'/contact/'。
我如何将它用于博客文章:
permalink: /blog/:title/
Run Code Online (Sandbox Code Playgroud)
这确保路径包含(sluggified)标题。
我如何将它用于收藏:
permalink: /desiredpath/:name/
Run Code Online (Sandbox Code Playgroud)
这确保路径包含文件名。
如果您不生成博客页面,则可以在目录结构中创建映射到某些URL的文件.如果您的目录具有结构,则在localhost上运行
- _layouts/
- config.yml
- index.html
- some_other_page.html
- some_directory/
- index.html
- some_sub_page.html
Run Code Online (Sandbox Code Playgroud)
在jekyll处理完文件后,您将在以下位置获得内容:
0.0.0.0:4000 (index.html的)0.0.0.0:4000/some_other_page.html (some_other_page.html)0.0.0.0:4000/some_directory (some_directory/index.html中)0.0.0.0:4000/some_directory/some_sub_page.html (some_directory/some_sub_page.html)您还可以使用每个帖子上的永久链接属性来手动设置,或者在config.yml中设置不同的默认值.永久链接只有一小部分可供使用的变量,需要在每个要放入的文件中定义.非标准的位置.
此目录结构也会自动对您的帖子进行分类.所以你可以:
- some_category (defined in the yaml front matter or the _config.yml
- index.html
- _posts/
- some_post.md
- some_other_post.md
Run Code Online (Sandbox Code Playgroud)
帖子会自动包含"某个类别"类别,而index.html会0.0.0.0:4000/some-category以默认的永久链接格式显示.类别变量:category以永久链接格式字符串形式提供.
我在寻找一种在_pages目录中组织 jekyll 页面的方法时遇到了这个老问题,类似于_posts. 然后访问此页面而不在 url 中显示整个路径。
对我来说效果更好的方法是使用jekyll 集合,如下所示:
1 -在以下位置添加页面集合_config.yml:
collections:
pages:
output: true
permalink: /:path/
Run Code Online (Sandbox Code Playgroud)
2 - 创建一个名为的新目录_pages(它应该具有相同的集合名称,以 为前缀_)
3 - 添加_pages文件夹中的页面,作为以 YAML Front Matter 开头的 .md 或 .html 文件。
例如。/_pages/about.md看起来像:
---
layout: page
---
<!-- about page content -->
Run Code Online (Sandbox Code Playgroud)
构建之后,关于页面的 URL 将是<your-web-site>/about.
或者,要显示集合名称,您必须将其永久链接定义为:
permalink: /:collection/:path/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15507 次 |
| 最近记录: |