jekyll / jekyll-redirect-from

:twisted_rightwards_arrows: Seamlessly specify multiple redirections URLs for your pages and posts.
MIT License
781 stars 112 forks source link

How to allow "redirect_from" for Page descendant #143

Closed tsv2013 closed 7 years ago

tsv2013 commented 7 years ago

I've a class: class ExamplePage < Page. And I want to use redirect_from frontmatter parameter in my custom ExamplePage. How can I achieve this?

benbalter commented 7 years ago

The plugin currently only supports Pages and Documents. Can you explain a bit more about what you're using a custom content class for?

tsv2013 commented 7 years ago

I've implemented custom generator for my Jekyll site. This generator produces ExamplePages. I'd like to set up redirect options for some of this pages, but I'm not able to make it work.

benbalter commented 7 years ago

See https://github.com/jekyll/jekyll-redirect-from/blob/master/lib/jekyll-redirect-from/generator.rb#L15-L19. That's not something that this plugin is likely going to support natively, but you should be able to implement it with your custom generator, if you wish.

tsv2013 commented 7 years ago

I've solved my task this way: added a "jekyll-redirect-from.rb" file in my "_plugins" folder and patch classes registration: CLASSES = [Jekyll::Page, Jekyll::Document, Jekyll::ExamplePage].freeze