16
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
this post was submitted on 10 Oct 2026
16 points (94.4% liked)
Programming
28795 readers
163 users here now
Welcome to the main community in programming.dev! Feel free to post anything relating to programming here!
Cross posting is strongly encouraged in the instance. If you feel your post or another person's post makes sense in another community cross post into it.
Hope you enjoy the instance!
Rules
Rules
- Follow the programming.dev instance rules
- Keep content related to programming in some way
- If you're posting long videos try to add in some form of tldr for those who don't want to watch videos
Wormhole
Follow the wormhole through a path of communities !webdev@programming.dev
founded 3 years ago
MODERATORS
How are you accessing the website? Are you using a web server like
miniserveor are you just opening the HTML files in a browser?Beginning a path with
/makes the path absolute for that origin. An origin is basically the URL's scheme, domain, subdomains, and port (sohttps://www.example.com/foo/barhas the originhttps://www.example.com/- ignore the trailing slash, Lemmy keeps adding it...). If your URL begins withfile://then absolute paths will likely be absolute to your filesystem, not relative to your project's directory.If you can, try serving the directory with something like miniserve and see if it works. It'll give you a better picture of what the website would look like if it were published for real. Otherwise, you can make the path relative to solve the problem without doing that.
Am opening the html files in a web browser by double clicking it.
Yeah, that makes sense. Thanks.
Is there any other way I can define the path so the update directly visible in the web browser? Or the only way to do it is by changing the file structure?
Removing the leading slash should make it relative to the file
Yes, by pointing multiple times to the parent directory, the issue is solved.
<link rel="stylesheet" href="../../styles/style.css" /><link rel="icon" type="image/png" href="../../images/favicon.png" />Usually when it’s hosted on a server it’s not this intricate and your first attempt would’ve worked, if you have Python installed you can see what it would look like by running
python3 -m http.serverfrom a terminal in the project folder