-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
feat(permalink): add pretty_urls option to remove index.html from url #3691
Conversation
|
I opt for |
The |
+1 Maybe we can find more better naming. And I would like to implement a trailing slash option. _config.yml
# following namings are an example.
url_trailing:
include_html: true # https://example.com/foo/index.html
slash: true # This option will be enabled if include_html is false. https://example.com/foo/ If we implement this idea user can select which they use from three patterns url.
But, I'm worry followings if implement trailing slash option.
How do you think? |
I'm aware of that, what I meant is the end goal is the same, which is to tell the links to search engines or readers that the links without "index.html" is the canonical version. I dismissed the idea But I do like the suggestion by @yoshinorin trailing_url:
include_html: true
trailing_slash: true
Sounds good. |
I changed the option to: trailing_url:
trailing_index: true |
LGTM! |
Thanks. Anyway, this can defer to v4.1. |
just stumbled upon Cryogen which uses option, clean-urls: 'trailing-slash' |
Sorry so late reply.
Is this mean to specify the option by a string? If yes, it seems a better way. |
Specify by string means only one option though. handling multiple options in an array can be awkward. What about |
From Netlify dashboard there is an option: We might name the config like: {
"pretty_urls": {
"trailing_index": false,
"trailing_html": false,
"trailing_slash": true
}
} |
Done 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Also, should we bring up |
Yes, if possible. |
@yoshinorin I might implement it after #3708 & #3710 merged. |
- pretty_urls.trailing_index: hexojs/hexo#3691 - external_link.enable: hexojs/hexo#3675 - meta_generator: hexojs/hexo#3653 - use_date_for_updated: hexojs/hexo#3235
- pretty_urls.trailing_index: hexojs/hexo#3691 - external_link.enable: hexojs/hexo#3675 - meta_generator: hexojs/hexo#3653 - use_date_for_updated: hexojs/hexo#3235
- pretty_urls.trailing_index: hexojs/hexo#3691 - external_link.enable: hexojs/hexo#3675 - meta_generator: hexojs/hexo#3653 - use_date_for_updated: hexojs/hexo#3235
- pretty_urls.trailing_index: hexojs/hexo#3691 - external_link.enable: hexojs/hexo#3675 - meta_generator: hexojs/hexo#3653 - use_date_for_updated: hexojs/hexo#3235
What does it do?
Currently
permalink
variable of post, page, tag, category may end with "index.html". This PR addscanonical_url
option to remove that.canonical_url
defaults to false to avoid breaking change.This is useful for SEO when web server (including
hexo server
) rewrite "index.html", so the url without it is the canonical version.This way, plugins that use post.permalink don't need to remove it. Tested with hexo-generator-sitemap.
Related:
Note this PR doesn't cover
this.url
(#3661).New option:
How to test
Pull request tasks
Fixes #1306 cc @sapegin @pyyzcwg2833