Jekyll redirects to a 404 and does not render post.md

I want my index.md seen at

to redirect to pages I have written in markdown

I tried implementing, post_url variable , such as documented
in order to successful redirect to a page written in markdown without success, as it points to a 404 at

[Name of Link]({% post_url 2010-07-21-name-of-post %})

Image taken from jekyllrb.com/docs/liquid/tags/#linking-to-posts

At first I thought this was an error from the for loop, so I added the link manually as detailed in the documentation specifically for pages written in markdown.

index.md

# Index of all my content

[Library Carpentry Workshop July 2020]({% post_url 2020-07-27-library-carpentry-workshop-american-university-notes %})


<ul>
  {% for post in site.posts %}
    <li>
      <a href="{{ post.url }}">{{ post.title }}</a>
    </li>
  {% endfor %}
</ul>

_config.yml

theme: jekyll-theme-slate
url: https://jtm-lis.github.io
baseurl: /Julien_Tremblay_McLellan #NO TRAILING SLASH
title: Julien Tremblay McLellan's Website
author: Julien Tremblay McLellan
email: jtremc@gmail.com
description: > # this means to ignore newlines until "baseurl:"
  Write an awesome description for your new site here. You can edit this
  line in _config.yml. It will appear in your document head meta (for
  Google search results) and in your feed.xml site description.
# social links
twitter_username: jtm-lis # DO NOT include the @ character, or else the build will fail!
github_username:  jtm-lis # DO NOT include the @ character, or else the build will fail!

show_excerpts: true # set to false to remove excerpts on the homepage

New users can only post 2 links.

What am I doing wrong?

It looks like the links that are being generated from this code are missing the repository name baseurl Julien_Tremblay_McLellan/ from the URL.

e.g. the link to your site is:

https://jtm-lis.github.io/Julien_Tremblay_McLellan/

However, the URLs that are being generated look like the following:

https://jtm-lis.github.io/2020/07/27/library-carpentry-workshop-american-university-notes.html

This results in a 404 as it’s missing the repository name Julien_Tremblay_McLellan/, which is the baseurl value, from the URL.

Note that the Jekyll website mentions that you don’t need to do this as of Jekyll version 4.0. However, GitHub Pages still runs Jekyll 3.8.7 underneath so you will need to manually include the baseurl.

There are two ways you can fix this. The first—and probably the best, if this is a personal blogging website—is to turn this Pages site into a User Pages site. To do this you’ll need to rename your repository from Julien_Tremblay_McLellan to jtm-lis.github.io. This will change your site’s URL to https://jtm-lis.github.io/ and these generated links should now work.

Alternatively you can modify the code to automatically include the baseurl when generating these links. The easiest way to do this would be to turn these links into a relative URL:

<ul>
  {% for post in site.posts %}
    <li>
      <a href="{{ post.url | relative_url }}">{{ post.title }}</a>
    </li>
  {% endfor %}
</ul>

If you’re going to use the first method I’d probably recommend you also do the second too, but both should do the job!

2 Likes

Thank you so much @thomasshaped !! It worked.