#is it possible to render html from public folder?

12 messages · Page 1 of 1 (latest)

steady path
#

I have many html files with examples, that import css and js files.
I want to show them in an iframe, so I put them in anfolder under public. I can ser the css, js, etc, but html files return 404 errors.
Is there a way to achieve this?

tame tartan
#

Interesting. I’d expect that to work, so might be a bug?

#

!issue

grim ospreyBOT
tame tartan
#

As a quick work-around, you maybe able to place the .html files in src/pages/. Those should get copied to your final build output.

steady path
#

Yes, but then I should redo the internal links. But I'll give it a try, thanks!

tame tartan
#

You shouldn't need to I don't think? For example src/pages/bread/index.html and public/bread/index.html should be equivalent I think.

urban yacht
#

I've achieved exactly what you describe, perhaps my repo can inspire your solution.

I made an EmbedLayout which extends my base layout. This way I still have my main site navigation around the embedded page. https://github.com/tvandinther/mioi/blob/master/src/layouts/EmbedLayout.astro

Then I placed my original webpages into folders in public. E.g. public/legacy_pages/index.html

Finally I made pages which used the embed layout for the intended access point of the legacy pages. https://github.com/tvandinther/mioi/blob/master/src/pages/legacy/farmvalue.astro

Note that the folder in public has a different path to the pages in src It's possible still to navigate to the legacy pages directly, but the main site navigation keeps you within the base layout with the navigation.

GitHub

The repository powering mioi.io. Contribute to tvandinther/mioi development by creating an account on GitHub.

GitHub

The repository powering mioi.io. Contribute to tvandinther/mioi development by creating an account on GitHub.

steady path
#

I'll take a look, thanks!

steady path
tame tartan
#

If you have public/main.css you can refer to that file from any HTML file whether it is in public/ or src/pages/:

<link rel="stylesheet" href="/main.css">
steady path
#

thanks, i'll try it too