Internal linking is used to establish website architecture. If it's implemented correctly your content becomes more SEO-friendly.
Building internal links in Jekyll isn't such simple as putting
<a>
tag and passing direct URL to the href
attribute. Of course, if you do that, the link will work, but the reason, why
you should never do it, is that you have to update all the links pointing to
the page manually, if the page permalink changed.
Link to pages
A more efficient way to build internal links in Jekyll is using Liquid
link
tag. The tag accepts a document path string as a first
parameter and always renders a valid link to a page generated from the document. The
file path must include the original extension.
You choose to use {{ site.base_url }}
or not depending on whether
you want to generate absolute URLs.
Link to posts
If you want to generate links to posts, there is a special tag you can use.
The post_url
tag accepts a post path relative to the
_posts directory. Also, you don't have to include the file
extension.
Markdown links syntax
If you're building your pages with markdown, use the following examples to generate internal links.
Broken pages validation
Both link
and post_url
tags have built-in link
validation. If the file path you specify doesn’t exist, Jekyll will fail
building your website. It allows you to catch broken links and fix them
before deploying a website.