Svelte routing - how do I handle a page and directory of the same name?
02:32 25 Sep 2026

My static website has a "posts" section, and I would like to have a list of all published posts on https://example.com/posts and then each post available at https://example.com/posts/post_title.

That seems like a reasonable thing to want, and my files are therefore as such:

example
  |__ src
    |__ routes
      |__ posts
        |__ +page.svelte
        |__ post_title1
          |__ +page.svelte
        |__ post_title2
          |__ +page.svelte

That works when I test out the website and when I navigate between the pages.

However, when I run and deploy and go straight to https://example.com/posts, this seems understood as me trying to display the "posts" directory that contains the various posts, instead of the page itself.

I already have the following in my .htaccess file to display /page.html when browsing /page.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.html [NC,L]

I have tried playing some more with the .htaccess file, but to no avail.

For now, I decided to have my posts listed at example.com/posts and to have each individual post (in the singular) at example.com/post/post_title. That solves the issue, but it is a pain to have to go back and forth between the /post and /posts folders.

You can still see the issue at https://edcstiftung.eu/projects which fails to load, while it is accessible when navigating to it from the homepage. I left the issue unfixed for the projects page as an example, but hope to correct both posts and projects in the future.

routes svelte sveltekit