okjuan / vbook

0 stars 0 forks source link

post_url_with_hover_card translates to incorrect link! #9

Closed okjuan closed 6 months ago

okjuan commented 6 months ago

{% post_url_with_hover_card last update | 2024-02-19-now %} gets turned into a link for the wrong now post, 2023-11-21-now.md for some reason!

okjuan commented 6 months ago

The cause was that post.id for all now pages was /now for some reason.

As explained by GitHub Copilot:

In Jekyll, the id of a post is automatically generated from the filename of the post, not from the permalink specified in the front matter. The id is created by combining the post's category (if it has one), the date of the post, and the title of the post. It's formatted as a path, like /category/2008/12/14/post-title.

In your case, the filename of the post is 2023-11-21-now.md, so the id of the post is /now.

Really, Jekyll only includes categories in the ID:

In Jekyll, if a post is nested under folders, those folders are considered as categories and are included in the post's id.

For example, if a post is located at _posts/2023/11/21/now.md, the id of the post would be /2023/11/21/now.

This is because Jekyll treats any folders inside the _posts directory as categories. The id of a post includes its categories, followed by the title of the post.

So, if you want the date to be included in the id of the post, you could structure your _posts directory with date folders like 2023/11/21/. However, this would also mean that the post is in the categories 2023, 11, and 21, which might not be what you want.

See this discussion.