What are the steps to getting this 'custom' permalink scheme in Jekyll?

ぐ巨炮叔叔 提交于 2019-12-11 10:53:40

问题


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

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