Jekyll带有Markdown的无扩展永久链接 [英] Jekyll extension-less permalinks with markdown
问题描述
在Jekyll中 docs 说(使用.md
格式):
From the Jekyll docs it says (using .md
format):
干净的URL也可以使用
permalink
前题变量来实现.在上面的示例中,使用第一种方法,可以通过在文件顶部设置permalink: /other
Clean URLs can also be achieved using the
permalink
front matter variable. In the example above, using the first method, you can get URLhttp://example.com/other
for the fileother.md
by setting this at the top of the file:permalink: /other
这是我的页面首页问题的一个示例:
Here is an example my page front matter:
---
layout: page
title: Contact
permalink: /contact
---
当我使用jekyll serve
时,一切正常,但是当我build
并上传到静态主机时,它却无法正常工作. Jekyll输出的文件结构对其在文档中声称的功能没有意义.
Everything works fine when I'm using jekyll serve
but when I build
and upload to my static host it doesn't work. The file structure Jekyll outputs doesn't make sense for the functionality it claims from the docs.
.
|-- css/
|-- index.html # => http://example.com/
└── contact.md # => http://example.com/contact.html
我希望能够转到http://example.com/contact
并显示contact.md
.我知道可以通过手动将文件放在文件夹中(然后将它们全部重命名为index.html
)来具有类似的功能,就像docs
I want to be able to go to http://example.com/contact
and have it show contact.md
. I know I could have similar functionality by manually putting my files in folders (and then renaming them all to index.html
) like it says in the docs here, but I don't want to have to go through the extra step and I don't prefer the trailing /
e.g. http://example.com/other/
.
我正在使用Jekyll 3.0.1
我找到了这些问题,但它们并没有解决我所面临的问题.
I have found these questions but they don't address the problem I'm facing.
如何链接到具有以下内容的页面在Jekyll中没有html扩展名的page.url?
如何使所有帖子都具有自定义格式"domain.com/blog/title"的永久链接?
推荐答案
我认为您做得正确,这只是正确配置Web服务器的问题(假设它支持删除扩展名).它在本地正常工作,因为默认情况下内置的jekyll Web服务器可以做到这一点.文档在此处提供有关此信息:
I think you are doing it correctly, it is just a matter of configuring your webserver properly (assuming it supports removing the extension). It works properly locally cause the built in jekyll webserver can do it by default. The docs have info on this here:
http://jekyllrb.com/docs/permalinks/#extensionless-permalinks
在AWS S3上,您可以通过上载没有扩展名的文件,然后将内容类型设置为text/html来使用无扩展名的URL进行托管.我认为不可能让jekyll以contact
的形式输出contact.html
而没有扩展名.因此,您可以在Web服务器上删除该扩展名(如果支持)(在s3上,我使用结尾的/).
On AWS S3 it says you can host with extensionless urls by uploading files with no extension at all, and then setting the content type to text/html. I don't think it is possible to get jekyll to output contact.html
as just contact
with no extension. So you get the web server to remove the extension, if it supports that (on s3 I use the trailing /).
这也有一些有趣的信息: https://github.com/jekyll/jekyll/issues/3345
This has some interesting info too: https://github.com/jekyll/jekyll/issues/3345
这篇关于Jekyll带有Markdown的无扩展永久链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!