Skip to content

Instantly share code, notes, and snippets.

@peey
Last active October 19, 2023 12:14
Show Gist options
  • Save peey/897e8ed33e412fdfe0fcacf002acc150 to your computer and use it in GitHub Desktop.
Save peey/897e8ed33e412fdfe0fcacf002acc150 to your computer and use it in GitHub Desktop.
Jekyll plugin for parsing of custom variables in permalinks
# will substitute :author with the variable author in your file (also works with defaults).
permalink: /:author/:slug/
# You need to have this extra permalink_custom_vars array to tell the plugin which substitutions to make
permalink_custom_vars: ['author']
# Note that you don't have to include the supported variables in this list as jekyll takes care of that
# For a complete list of variables jekyll supports, see: https://jekyllrb.com/docs/permalinks/#template-variables
@andreamoro
Copy link

andreamoro commented May 22, 2022

Hello @peey
Does this work with the modern version of Jekyll? I'm trying to make it something for the pages, where if they contains a :slug, this is going to be forming the pemalink later without success.

In fact, even a simple, hardcoded replacement is ignored.

 	if p.data['slug'].include?("/test/") 
            puts("rewriting the permalink")
            permalink = p.data['permalink'] = "/newurl"
       end

Do you have any idea?
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment