使用前面的标题作为 url 永久链接

Using front matter title as for url permalink

如何使用我的前言代替文件名?url?

我在 _config.yml

中设置了 collection
collections:
      news:
        output: true

我希望能够使用page.title作为我的url,下面是我的前言

---
layout: newspost
title:  "Fracture announces exclusive 3 year deal with Drake & Morgan."
date:   2019-01-16
---

目前 url 是 .md 文件的文件名:

http://localhost:4000/news/drake_and_morgan.html

我希望 url 的输出如下:

http://localhost:4000/news/Fracture-announces-exclusive-3-year-deal with-Drake-&-Morgan. 或类似的。

_config.yml

collections:
  news:
    output: true
    permalink: /news/:title

你可以在前面定义一个slug :

---
layout: newspost
title:  "Fracture announces exclusive 3 year deal with Drake & Morgan."
date:   2019-01-16
slug: "fracture-announces-exclusive-3-year-deal-with-drake-and-morgan"
---

并为新闻定义默认 permalink :

collections:
  news:
    output: true
    permalink: "/:collection/:slug/"

您可以在文件名上多做一些工作,最后得到 fracture-announces-exclusive-3-year-deal-with-drake-and-morgan.md 文件名。 ;-)