Markdown, relative links, Jekyll, and Github pages are playing well together
Markdown
Default Markdown parser for Jekyll is Kramdown. It allows you to write markdown in file (page.md or page.markdown) and in variables.
When you have some markdown in a variable, you can parse it with {{ variable | markdownify }}
Markdown links
Your example link ([a relative link](other_file.md)
) will render a perfect relative link from you page to the other_file.md sibling page.
You are free to use this syntax.
{{ site.baseurl }}
and {{ post.url }}
variables
Those variables are not mandatory in Jekyll.
{{ post.url }}
is often found in for loops and result in links like [{{ post.title }}]({{ post.url }})
and this is only automation. And you're not obliged to use automation.
{{ site.baseurl }}
(which is different from {{ site.url }}
) is a very useful variable to build links relative to site root.
A link like [a relative link](/other_file.md)
will only work if your site is at the root of a domain, because it converted like /other_file.html
.
If you site is hosted at domain.tld.blog
, this link will miss is target.
If you set baseurl: /blog
in your _config.yml
file.
Adding [a relative link]({{ site.baseurl }}/other_file.md)
will give you the perfect relative link to root : /blog/other_file.html
.