-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
clean-url plugin breaks Netlify deployment #1385
Comments
I admit that I did not clarify this in the document and I will add some caveats to it. VuePress does not have the right to modify server identification. If you want your URLs to follow a certain pattern (e.g. However, I still don't know why plugin-clean-urls works in your master branch. @jjyyxx Here is a related issue: #1382. |
@shigma I see. Handling pages as HTML is a server's responsibility.
The thing is that I actually do not have this plugin enabled in the master branch. I double-checked that Netlify has asset optimization disabled (and even forcibly re-deployed the site). Still, https://docs.onyxframework.org/getting-started is working (but immediately gets redirected to https://docs.onyxframework.org/getting-started.html). So, looks like it's some Netlify stuff. Nevertheless, is it somehow possible to make https://docs.onyxframework.org/getting-started links work without redirecting to |
Most of the servers will automatically handle some redirects, e.g. when
(And to behonest, #1269 does not work on any server.) So if you want a
|
@shigma in my case on master branch the
Both https://docs.onyxframework.org/getting-started.html and https://docs.onyxframework.org/getting-started work. And the bug branch (with
Neither https://compassionate-benz-c091d6.netlify.com/getting-started nor https://compassionate-benz-c091d6.netlify.com/getting-started.html work. This falls under your advice:
But does not work. Netlify doesn't want to treat |
I made a little hotfix-script. Place following in your package.json "scipts": {
"build": "vuepress build; npm run urls:pretty",
"urls:pretty": "find ./.vuepress/dist ! -path './img*' ! -path './assets*' ! -name '_redirects' ! -name '*.*' -type f -exec bash -c 'mv $1 $1.temp; mkdir $1; mv $1.temp $1/index.html' - {} \\;"
} and run You'll might have to adjust the filter of the script, so that it doesn't rename your assets, etc. You have to disable Netlify's "pretty URLs" to get rid of the trailing slashes |
Another workaround for using the clean-url plugin with netlify. Set the content-type header in netlify.toml or a _headers for your specific paths, i.e. netlify.toml:
However, I do still think this is a bug. You should be able to set the path as /posts/my-page and have vuepress write out /posts/my-page.html. That is the typical solution for non-spa static files and hosts have server rules to handle that. I don't see how a plugin can solve that since when vuepress renders the page the filename is based on the path, even if regularPath still has the html extension.
|
The problem with setting Netlify headers is that your own CSS for the page doesn't get rendered, only the browser defaults. At least, this was my experience. |
Bug report
Version
alpha.40
Steps to reproduce
Visit https://compassionate-benz-c091d6.netlify.com/getting-started
What is expected?
A rendered page equal to https://docs.onyxframework.org/getting-started
What is actually happening?
Both websites are deployed via Netlify. https://docs.onyxframework.org is deployed from
master
branch, https://compassionate-benz-c091d6.netlify.com — frombug
branch. The only difference is that theclean-urls
plugin enabled inbug
branch as seen here: https://github.com/onyxframework/docs/compare/bug.See https://github.com/onyxframework/docs for the source code.
Other relevant information
_redirect
file is present in neither of deploymentsThe text was updated successfully, but these errors were encountered: