5

I want to implement static HTML website with multiple languages using Hakyll framework. I didn't come up with better solution than just put default language under website.com route and any other custom language at website.com/en route. Because I'm using static HTML and having multiple languages I should have multiple versions of every page, for example about.html. Such pages are generated automatically, so that's not a problem. But currently I have a problem with jumping those pages...

I have such link in my website.com/index.html:

<a href=about.html>

When I open this link from website.com/en I want to jump to website.com/en/about.html instead of website.com/about.html. But in reality I'm jumping from website.com/en to website.com/about.html. If I instead jump from website.com/en/index.html I go to website.com/en/about.html as I want. So I'm inserested in one of two possible solutions:

  1. When I go to website.com/en I want to be redirected to website.com/en/index.html. I can see content of index.html from website.com/en but somehow I can't jump to relative link :(
  2. Replace href=about.html with something more smart so I can automatically go folder/about.html from any folder.

Any help appreciated!

Shersh
  • 9,019
  • 3
  • 33
  • 61
  • Shouldn't `website.com/en` redirect to `website.com/en/index.html`, from where that relative link does indeed work? – Bergi Mar 27 '18 at 01:57
  • @Bergi This is exactly what I've asked for: `When I go to website.com/en I want to be redirected to website.com/en/index.html`. When I need to go to `website.com/en` from any link on my I can manually set this link to `website.com/en/index.html` but it's still possible in Hakyll (as I can see) to enter manually `website.com/en` directly in browser address bar and the resulting link will look like `website.com/en/`. I don't know to automatically redirect this to `index.html`. – Shersh Mar 28 '18 at 14:46
  • Are you using an Apache webserver? With [`DirectorySlash On`](http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryslash) and [`DirectoryIndex index.html`](http://httpd.apache.org/docs/2.2/mod/mod_dir.html#directoryindex) (both of which are the defaults), the `website.com/en` should be 301-redirected to `website.com/en/` which in turn will display the content of the index.html file, and relative links on that url do work for me. – Bergi Mar 28 '18 at 15:01
  • @Bergi Hmm, I'm not aware of DevOps part of web-server deployment. But as I see now `website.com/en` redirects to `website.com/en/` indeed! Thanks a lot! – Shersh Mar 30 '18 at 10:40
  • html redirects are not good practice, why won't you use .htaccess or the backend redirect (say PHP)? – PalDev Apr 08 '18 at 20:59

0 Answers0