在 jekyll 的配置文件中定义目录特定的永久链接
defining Directory specific permalinks in the config file in jekyll
我正在使用 jekyll 在网站上工作。我想更改目录中所有页面的 url 而不必在每个前面写永久链接:url。
我在页面中有一个目录作业
pages
jobs
example.markdown
otherexample.markdown
我希望作业中的所有页面都有 url /talent/filename。
我看到 并尝试了这个:
defaults:
-
scope:
path: 'pages/jobs'
type: 'pages'
values:
permalink: 'talent/:slug'
_site 目录中的结果是这样的:
Talent
:slug
index.html
其他页面完全消失了。我已经尝试了 here 中列出的许多变量,结果相似。有谁知道是怎么回事吗?
谢谢。
您忘记在路径中添加尾部斜杠“/”。
下面的示例应该会为您提供所需的生成输出。
如果您已全局设置 permalink: pretty
,它将为每个标题创建一个文件夹,其中包含一个 index.html
如果不仅仅是 yourtitle.html
这样的文件
defaults:
-
scope:
path: "pages/jobs"
type: "pages"
values:
permalink: /talent/:basename.html
我正在使用 jekyll 在网站上工作。我想更改目录中所有页面的 url 而不必在每个前面写永久链接:url。
我在页面中有一个目录作业
pages
jobs
example.markdown
otherexample.markdown
我希望作业中的所有页面都有 url /talent/filename。
我看到
defaults:
-
scope:
path: 'pages/jobs'
type: 'pages'
values:
permalink: 'talent/:slug'
_site 目录中的结果是这样的:
Talent
:slug
index.html
其他页面完全消失了。我已经尝试了 here 中列出的许多变量,结果相似。有谁知道是怎么回事吗?
谢谢。
您忘记在路径中添加尾部斜杠“/”。
下面的示例应该会为您提供所需的生成输出。
如果您已全局设置 permalink: pretty
,它将为每个标题创建一个文件夹,其中包含一个 index.html
如果不仅仅是 yourtitle.html
这样的文件defaults:
-
scope:
path: "pages/jobs"
type: "pages"
values:
permalink: /talent/:basename.html