I want to tweak the permalink of each page programatically, using permalink templates is not enough. I tried using a Generator plugin, something like:
module MySite
class MySiteGenerator < Jekyll::Generator
def generate(site)
site.pages.each do |page|
page.data['permalink'] = '/foo' + page.url
# real world manipulation of course more complicated
end
end
end
end
But although this would run and set the page.data['permalink'] field, the output was still the same.
On Stack Overflow I got the suggestion to instead override the Page class, like:
module Jekyll
class Page
alias orig_permalink permalink
def permalink
permalink = orig_permalink
newPermalink = "foo/#{permalink}"
end
end
end
But this didn't work either, only if a page had a manually configured permalink in the front matter did it work, otherwise the pages were not generated in _site at all. Here's a test repo.
This repository is no longer maintained. Please search for your issue on Jekyll Talk, our new community forum. If it isn't there, feel free to post to the Help category and someone will assist you. Thanks!
I asked this question on Stack Overflow but thought it would be good to ask as well, sorry if some of you already read this.
I want to tweak the permalink of each page programatically, using permalink templates is not enough. I tried using a Generator plugin, something like:
But although this would run and set the
page.data['permalink']
field, the output was still the same.On Stack Overflow I got the suggestion to instead override the
Page
class, like:But this didn't work either, only if a page had a manually configured permalink in the front matter did it work, otherwise the pages were not generated in
_site
at all. Here's a test repo.Is there a way to get what I want? Thanks!