I have the following Netlify site: https://willcarh.art. I’m trying to set up URL routing.
The site is built from a custom static-site generator and puts generated files into a src/
folder. However, index.html
is still in the root. For example, the file page.html
is actually src/page.html
in the file tree. I’d like to set up the URL for the site to still be just /page
.
Here’s a more concrete example. The index page for the blog can be found in /src/blog_index.html
. I would the like the blog URL to be /blog
, but point to the file /src/blog_index.html
without changing the URL. A couple questions:
- is it possible for the user to use URL
/src/blog_index.html
but have the URL resolve to/blog
while serving/src/blog_index.html
, even though there’s no actual file/blog
or/blog.html
? - do my internal hrefs to other site pages (e.g. the home page to the blog page) need to use
/blog
, then? It is easier during development to link to the actual page (e.g./src/blog_index.html
) so the site works locally - if I use redirects, and a page links to
/src/blog_index.html
, will/src/blog_index.html
appear in the URL briefly before it is redirected to/blog
?
I have tried the following to achieve this, none of which work because there’s no file to serve at /blog.html
. In _redirects
:
/src/blog_index /blog
/src/blog_index.html /blog
/src/blog /blog
/src/blog.html /blog
In netlify.toml
:
[[redirects]]
from = "/src/blog_index.html"
to = "/blog"
status = 200
Repo: GitHub - wcarhart/willcarh.art: Personal porfolio website, custom static site generator