Reputation: 81
I want to create a very simple jekyll site hosted on GH pages. However, I can't seem to get it to work. I am not using Jekyll directly and am using GH for all of the coding actually.
My directory is as follows:
_config.yml
index.md
/_posts
2021-12-31-post.md
My _config.yml
file simply consists of one line:
theme: jekyll-theme-minimal
I simply want the index home page to display links to all of the posts. As such, I added this snippet to index.md
directly taken from Jekyll's documentation:
<ul>
{% for post in site.posts %}
<li>
<a href="{{ post.url }}">{{ post.title }}</a>
</li>
{% endfor %}
</ul>
This correctly displays list of posts on the index page. However, the links are broken. For example, when clicking the link given for the singular post, it goes to username.github.io/2021-12-31-post/
which won't work because my repository is named, for example, as blog
. When I manually type username.github.io/blog/2021-12-31-post/
, the post shows.
So I guess this boils down into post.url
not giving the correct link.
How could I fix this?
Thanks!
Upvotes: 2
Views: 161
Reputation: 81
Fixed. Needed to prepend base.url
to the link:
href="{{ post.url | prepend: site.baseurl }}"
and add the baseurl
in the config file.
Upvotes: 2