HTML files placed in .vuepress/public are only sporadically available. Trying to navigate to them from a link elsewhere on the site results in a 404. However, reloading the page finds the content.
0.14.4
Create an .html file and place it in .vuepress/public. Create a link to it from another page on the site. try to follow the link.
I expect the page to load
We get a 404 error until the reload button is clicked.
Sorry but could you create a reproduction repo, I can basically confirm that what you said above is not an issue, or our website will not work.
Hi! I met this problem too, this is a small reproducer https://github.com/BillyYccc/vuepress-reproducer, can you please take a look at it?
Yes, Billy's example is what I was talking about.
@ulivz ping
Same issue here. What I did notice was that you could cp index.html README.md (and leave it as is) and it works. ln -s index.html README.md does not work. You can also create a README.md and just paste in the relevant html, tags and all, and it will work too. But handling .html files directly didn't work for me.
macOS Sierra Vuepress 0.14.9 npm 6.8.0 [email protected] global install, vuepress dev mode, node v10.15.0
@ulivz I believe this should no longer be marked "needs reproduction repo"
As a workaround, I've created the following component, to be dropped in .vuepress/components/StaticLink.vue:
<script>
export default {
name: "StaticLink",
render(h) {
return h("a", { domProps: this.props }, this.$slots.default);
}
};
</script>
Then, in a markdown file, you can use it like an a-tag, but it opts-out of vuepress' router behavior. In this example, I have a folder full of html at .vuepress/public/rdoc/
<StaticLink href="/rdoc/">Rdocs</StaticLink>
Getting the same problem here, also want to be able to reference static HTML docs from the navbar links defined in config.js. e.g.:
{ text: 'Links to HTML loaded in public folder', link: '/test.html'}
Me too. I have an external HTML file I need to host, but using the []() syntax in markdown to link to it doesn't work. My workaround is to write the link using the <a> element directly in the markdown file.
I have the same problem as @mhyrr, any other workaround than setting <a> elemenet in Markdown files?
Has there been any movement on this?
I confirm that link in navbar to an html file is broken.
So basically, you can't use relative link to navigate to HTML files place under .vuepress/public folder, which I personally believe it's expected? Because the purpose of the public file is:
You may need to provide static assets that are not directly referenced in any of your Markdown or theme components - for example, favicons and PWA icons.
Everything you place under the public folder will be simply copied into the root directory. So the HTML files won't be registered as a page in the Vue-router, which causes the 404. And when you refresh the page or navigate to it by the absolute link, the page will be correctly fetched and displayed.
As for workarounds:
If you are looking for a fully customized page (without any layout pre-defined in the VuePress), which I believe you are since you try to use HTML files. You can:
public folder (Which I personally recommend)public folder and use absolute link to navigate to themIf you want the HTML files to be treated like any other MarkDown files, you can simply rename it to *.md and move it out of the public folder, because MarkDown naturally supports HTML syntax, it should be working fine for now.
I think the real issue is not navigating to HTML files underpublic, is whether to support raw HTML files like:
โโโ docs
โโโ .vuepress/
โโโ guide
โ โโโ test.html
โ โโโ README.md
โโโ README.md
Most helpful comment
So basically, you can't use relative link to navigate to HTML files place under
.vuepress/publicfolder, which I personally believe it's expected? Because the purpose of thepublicfile is:Everything you place under the
publicfolder will be simply copied into the root directory. So the HTML files won't be registered as a page in the Vue-router, which causes the 404. And when you refresh the page or navigate to it by the absolute link, the page will be correctly fetched and displayed.As for workarounds:
If you are looking for a fully customized page (without any layout pre-defined in the VuePress), which I believe you are since you try to use HTML files. You can:
publicfolder (Which I personally recommend)publicfolder and use absolute link to navigate to themIf you want the HTML files to be treated like any other MarkDown files, you can simply rename it to
*.mdand move it out of thepublicfolder, because MarkDown naturally supports HTML syntax, it should be working fine for now.I think the real issue is not navigating to HTML files under
public, is whether to support raw HTML files like: