My Astro website works fine when I run it with astro run dev
and astro preview
but as soon as I run astro build and put the output (dist folder) on my website, I end up getting the website fine, but the css is not there. the CSS shows up in the dist folder, and the file paths are correct.
There was another person asking something similar on stackoverflow. Their solution was to upload the website to a webserver instead of double clicking. thats what I did and It is still not working.
this is what its supposed to look like:
but this is what it looks like on the server(thel1ama.com/dist)
When running astro build
it places the generated site content into a dist/
directory (by default).
It looks like instead of uploading the contents of dist/
, you uploaded the directory itself, making everything available at https://thel1ama.com/dist/ instead of https://thel1ama.com/.
This means that when trying to load CSS from e.g. /_astro/some.css
, it loads https://thel1ama.com/_astro/some.css
but the actual file is at https://thel1ama.com/dist/_astro/some.css
and is not found.
The fix you probably want is to make sure you upload all the files and folders inside dist/
to your web host root directory.