问题
I'm writing a Jekyll setup and I'd like to get my posts to have a permalink in the form: /2013/jan/something-something-in-january
. I understand that it is impossible with vanilla permalinks to:
- get the
:month
to be in text form or - get the
:title
to be dash delimited
I remember reading somewhere that I could achieve this by writing a plugin, but I'm not sure how. How can I do this?
回答1:
I created a generator plugin:
module Jekyll
class PermalinkRewriter < Generator
safe true
priority :low
def generate(site)
# Until Jekyll allows me to use :slug, I have to resort to this
site.posts.each do |item|
item.data['permalink'] = '/' + item.slug + '/'
end
end
end
end
来源:https://stackoverflow.com/questions/16235601/what-are-the-steps-to-getting-this-custom-permalink-scheme-in-jekyll