Multiple html files as pages

Hello,

I have some simple html files which should be my app pages.
I tried linking between them simply with a <a> link-
This works fine in the browser, on my phone however, I reveive a “Page not found error”

Can someone give me a hint what I am doing wrong?

All html files inside /src. Links look like <a href="about.html">.

Thanks and kind regards
Andreas

Not much info to go off of. What is your setup?

Assuming you’ve followed the Capacitor installation docs? The default directory Capacitor syncs is www (source).

I think it would be helpful to study how modern web frameworks are working. Nowadays, <a> tag with linking a .html file directly is not a practice to route pages.

1 Like

Thanks for your answer. It was an issue with vite, as vite is per default not intended to use multiple html files, hence only the index.html was copied to the dist folder.
I switched to parcel and not it works fine.

Sorry about this. It was not an issue related to capacitor directly, but thanks nonetheless.

Kind regards
Andreas

1 Like

I kindly disagree :smile:
For simple usecases static html files work perfectly fine imho.

As an FYI, looks like Vite does support multi-page projects - Building for Production | Vite. The related feature/issue is here - Multi-page mode example · Issue #257 · vitejs/vite · GitHub.

You do have to define every page manually though in the Rollup config. So, someone created this package to auto-discover - GitHub - IndexXuan/vite-plugin-mpa: MPA(multi page application) for vite.

Thanks for the link to the auto-discover package! I was not aware it existed and abandoned vite because manually adding all pages to the config file was too tideous.

1 Like