Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url bug #84

Open
xiaopixiao opened this issue Nov 28, 2023 · 1 comment
Open

url bug #84

xiaopixiao opened this issue Nov 28, 2023 · 1 comment

Comments

@xiaopixiao
Copy link

If i write two posts named 2023-11-27-test.md and 2023-11-28-test.md, there addresses are all '/test' and it will point to the newer one, 2023-11-28-test.md.
But in the Jekyll, they will be different. One is '/2023/11/27/test' and the other is '2023/11/28/test'. I don't know how to fix this bug.

@sionta
Copy link

sionta commented Mar 30, 2024

The issue you're encountering is due to how Jekyll generates URLs for posts based on their file names. By default, Jekyll uses the file's date and slug to generate the URL.

To fix this issue and ensure that both posts have the same base URL (/test), you can manually set the permalink for each post in its front matter. Here's how you can do it:

For 2023-11-27-test.md:

---
date: 2023-11-27 11:58:47 +07:00
title: Test 1
permalink: /test/
---

Post content goes here.

For 2023-11-28-test.md:

---
date: 2023-11-28 11:58:47 +07:00
title: Test 2
permalink: /test/
---

Post content goes here.

Note: Date is required on format YYYY-MM-DD HH:MM:SS +/-TTTT

With this setup, both posts will have the same URL: /test/.

Keep in mind that setting a permalink in the front matter overrides the default URL generation based on the file name and date. So, make sure to choose a permalink that fits your requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants