jekyll - 使用前面的标题作为 url 永久链接
问题描述
如何将我的前端内容用作 url 而不是文件名?
我在我的收藏夹中设置了一个集合_config.yml
collections:
news:
output: true
我希望能够将其page.title
用作我的网址,以下是我的首要任务
---
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.
或类似的。
解决方案
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
并为 news定义一个默认值:
collections:
news:
output: true
permalink: "/:collection/:slug/"
或者
您可以在文件名上多做一些工作,最终得到一个fracture-announces-exclusive-3-year-deal-with-drake-and-morgan.md文件名。;-)
推荐阅读
- c# - 在 .NET 上等待多个任务
- html - 当视口变得太小时时,Flexbox 居中 2 个图像并缩放图像
- python - 如何提高我的网页抓取脚本(Python 和 Selenium)的性能(运行时)
- jenkins - 詹金斯的空手道选项
- javascript - 如何在 .then() 中设置一个变量以在以后的 .then() 中使用 - Firebase
- docusignapi - Docusign - 没有用于嵌入式签名的重定向 url
- c# - PayPal Rest API 突然出现 Instrument_Declined 错误
- python - 根据给定索引的值相似性对 numpy 数组进行分组
- r - 从 checkboxInput 更改图形
- javascript - 如何根据纵向或横向模式(和方向更改)更改“初始比例”?