Jekyll Filename Without Date

99封情书 提交于 2019-12-20 17:38:40

问题


I want to build documentation site using Jekyll and GitHub Pages. The problem is Jekyll only accept a filename under _posts with exact pattern like YYYY-MM-DD-your-title-is-here.md.

How can I post a page in Jekyll without this filename pattern? Something like:

  • awesome-title.md
  • yet-another-title.md
  • etc.md

Thanks for your advance.


回答1:


Don't use posts; posts are things with dates. Sounds like you probably want to use collections instead; you get all the power of Posts; but without the pesky date / naming requirements.

https://jekyllrb.com/docs/collections/

I use collections for almost everything that isn't a post. This is how my own site is configured to use collections for 'pages' as well as more specific sections of my site:




回答2:


I guess that you are annoyed with the post url http://domaine.tld/category/2014/11/22/post.html.

You cannot bypass the filename pattern for posts, but you can use permalink (see documentation).

_posts/2014-11-22-other-post.md

---
title:  "Other post"
date:   2014-11-22 09:49:00
permalink: anything-you-want
---

File will be anything-you-want/index.html.

Url will be http://domaine.tld/anything-you-want.



来源:https://stackoverflow.com/questions/27099427/jekyll-filename-without-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!