Search code examples
jekyllgithub-pages

Jekyll Links Missing Baseurl


Creating a blog using Jekyll and was hoping to link posts together using the following syntax:

either

[xyx]({% post_url 2020-07-17-xyx%})

or

[xyx]({% link _posts/2020-07-17-xyx.markdown %})

In both cases the link that is created is:

http://000.0.0.0:4000/jekyll/update/2020/07/16/xyx.html

instead of

http://000.0.0.0:4000/myblog/jekyll/update/2020/07/16/xyx.html

notice myblog is missing


Solution

  • It has to with the version of Jekyll. If one uses Jekyll 3 this does not work - I assume you have to prepend the base url (even if I am not sure how to do that). Using Jekyll 4 this works.

    Update for Jekyll 3 you prepend baseurl as follows

    {{site.baseurl}}
    

    therefore the complete syntax is

    [xyx]({{site.baseurl}}{% link _posts/2020-07-17-xyx.markdown %})