Skip to content

Restore legacy permalink behavior using :filepath pattern #5661

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dimaslanjaka
Copy link
Contributor

What does it do?

This PR introduces or adjusts the :filepath permalink pattern to replicate the previous behavior of :title, which was based on the post's file name and path under source/_posts/.

✅ What this PR does:

  • Restores old permalink behavior via :filepath
  • Enables backward compatibility for existing blogs without requiring manual changes to thousands of posts
  • Preserves legacy URLs and helps prevent SEO regressions or broken external links

🧪 How to test:

  1. Add the following to your _config.yml:
    permalink: :filepath/
  2. Make sure your posts inside source/_posts/ generate the expected permalinks matching the file name.

📌 Related Issue / Discussion:

🙏 Note:

This change helps long-time users maintain their blog structure and avoid unnecessary mass edits due to the breaking permalink change. Especially for blogger/wordpress users who have migrated to Hexo.

🔍 Test Results:

All posts render with the expected permalink structure using the :filepath pattern.

Screenshots

image
image

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

Copy link

github-actions bot commented May 5, 2025

How to test

git clone -b filepath-permalink https://github.com/dimaslanjaka/hexo.git
cd hexo
npm install
npm test

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

Successfully merging this pull request may close these issues.

1 participant