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

feat($core): redirects for clean urls #1269

Merged
merged 2 commits into from
Feb 8, 2019
Merged

feat($core): redirects for clean urls #1269

merged 2 commits into from
Feb 8, 2019

Conversation

ulivz
Copy link
Member

@ulivz ulivz commented Feb 8, 2019

Summary

In VuePress, we have following convention about routing:

  • /foo/ means source file is /foo/{README|index}.md
  • /foo.html means your source file is /foo.md

The original design of VuePress relied on above two styles
of routing, especially the calculation involved of routes at
// default theme. so we can't easily modify /foo.html directly
to /foo (i.e. remove html suffix)

This utility handles redirect of clean urls, with this utility, you'll
get:

For unknown request /foo

  • redirect to /foo.html if it exists
  • redirect to /foo/ if it exists

For unknown request /foo/

  • redirect to /foo.html if it exists

If all the above redirect rules don't exist, you'll get a 404


Note that this PR doesn't provide you the ability to remove the
html suffix at the route level, it just allows you to use clean urls.

cc @octref


Related: #603
Related: #608
Related: #1060
Close: #720
Close: #931

@ulivz ulivz force-pushed the clean-urls-redirect branch from c94bebf to 6fc435a Compare February 8, 2019 14:41
@ulivz ulivz merged commit 213bb34 into master Feb 8, 2019
@awulkan
Copy link

awulkan commented Feb 8, 2019

If I understood this correctly, the routes will still end in .html? Or am I wrong?

@ulivz ulivz deleted the clean-urls-redirect branch February 17, 2019 17:29
@ulivz
Copy link
Member Author

ulivz commented Feb 19, 2019

I have noted it in the description:

Note that this PR doesn't provide you the ability to remove the
html suffix at the route level, it just allows you to use clean urls.

FYI, we don't plan to support removing the html suffix for now(1.x)

@awulkan
Copy link

awulkan commented Feb 19, 2019

FYI, we don't plan to support removing the html suffix for now(1.x)

Oh, so that won't happen until 2.x? Which might not happen for a LONG time. :'(

I guess I'll use another static site generator for now then, because I can't afford losing search engine rankings when switching URL structure.

@shigma
Copy link
Collaborator

shigma commented Feb 27, 2019

@awulkan

Now you can use plugin-clean-urls if you want your urls to be /foo/ or even /foo instead of /foo.html.

@nelson6e65
Copy link
Contributor

OMG! Amazing, @shigma

@awulkan
Copy link

awulkan commented Feb 27, 2019

@shigma Well done. :)

Copy link
Member Author

@ulivz ulivz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just selected a wrong review target...

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