Search code examples
jekyllliquidpermalinks

How to set up permalinks with variables in jekyll?


I'm trying to setup jekyll so that it will automatically create permalinks for new posts but it's not working.

What I did is setting a variable in the _config.yml like this:

permalink: /:title/

then, in a loop of post previews on the homepage I created a link like this:

<a href="{{ post.permalink }}">Read More</a>

Expecting the output to be something like.

<a href="/I-am-the-title-of-this-post">Read More</a>

and instead I'm getting this:

<a href="/:title/">Read More</a>

which if I click gives a 404 Not Found error.

What am I doing wrong?

For more info here is the github repo.

Thanks!

Matteo


Solution

  • As @David Jaquel suggested I solved by using

    {{ site.baseurl }}{{ post.url }}