在jekyll的配置文件中定义目录特定的永久链接 [英] defining Directory specific permalinks in the config file in jekyll

查看:47
本文介绍了在jekyll的配置文件中定义目录特定的永久链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用jekyll的网站上工作.我想更改目录中所有页面的url,而不必写永久链接:每一个最重要的问题.

Im working on a site using jekyll. I want to change the url of all pages in a directory without having to write permalink: url in every front matter.

我在页面中有一个目录作业

I have a directory jobs in pages

 pages
    jobs
       example.markdown
       otherexample.markdown

我希望作业中的所有页面都具有url/talent/filename. 我看到了,并尝试了以下方法:

I want all pages in jobs to have the url /talent/filename. I saw this and tried this:

defaults:
-
   scope:
      path: 'pages/jobs'
      type: 'pages'
   values:
      permalink: 'talent/:slug'

_site目录中的结果为:

The result in the _site directory was this:

 Talent
    :slug
        index.html

,其他页面完全消失.我已经尝试在此处中列出的一些变量,结果相似.有人知道发生了什么吗?

with the other pages just vanishing entirely. I have tried a number of the variables listed here, with similar results. Does anyone know what is going on?

谢谢.

推荐答案

您忘记了路径中的尾部斜杠'/'.

下面的示例将为您提供所需的生成的输出.

the example below should give you the desired generated output.

如果您全局设置了permalink: pretty,则会为每个标题创建一个文件夹,并在其中包含index.html

if you have set permalink: pretty globally it would create a folder for each title with an index.html inside

如果不仅仅是像yourtitle.html这样的文件

if not just the files like yourtitle.html

defaults:
-
   scope:
      path: "pages/jobs"
      type: "pages"
   values:
      permalink: /talent/:basename.html

这篇关于在jekyll的配置文件中定义目录特定的永久链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆