Changing URLs in Jekyll

How to change pages’ URLs in Jekyll using a custom generator plugin.

We had some content in current directory and some in /content folder which was essentially another git repository. The problem was that the /content folder stayed in the path which wasn’t what we wanted (and changing document root was not possible).

So we implemented a simple generator plugin changing all urls starting with /content/. To do so, we had to make an attribute writer for url param of Jekyll::Page class since this isn’t otherwise possible. That’s how our simple generator looks like:

Another way is to just edit _config.yml file and change the permalink attribute, but than you need a special entry for every subdirectory.

Leave a comment

Your email address will not be published. Required fields are marked *