Open NathanRHD opened 2 years ago
This app is not specifically aimed at React or Angular framework. Maybe a dedicated app is relevant ? If not, adding a way to configure URL rewriting (through config panel?) should do the trick ?
This app is not specifically aimed at React or Angular framework. Maybe a dedicated app is relevant ? If not, adding a way to configure URL rewriting (through config panel?) should do the trick ?
As I say, this is not a behaviour specific to react or angular, but a part of general patterns such as SPA, which are supported by Web standards via the history api:
https://developer.mozilla.org/en-US/docs/Web/API/History/pushState
yes, such configuration might be a good way to solve it!
Also worth a look: https://en.wikipedia.org/wiki/Clean_URL#Implementation
Hi Nathan, if you want to implement clean URLs on your website, it is fairly simple. There are instructions at this website: https://www.hostnextra.com/kb/how-to-remove-html-extension-in-nginx
That example does exactly what you want, removing the ".html" from the URL. You want to add it to a newly created file at /etc/nginx/conf.d/nathanrhd.nohost.me.d/cleanurl.conf
(you can use whatever filename you want)
I confirm the problem and steps from the link (I needed to open it using Web Archive) didn't help me here. i will describe my case.
I have an Obsidian vault that I wanted to publish using Quartz generator. Generated website uses html
files under-the-hood but links on the website doesn't have that .html
suffix. In default my_webapp
settings it leads to redirecting to YH login page as there is no site found.
I see try_files
nginx function as the only way to fix that and based on official Quartz manual I modified automatically generated my_webapp.conf
file for my site - I needed to edit it as creating a new config file in my_webapp.d/
lead to an error as try_files
directive is already used for root location.
I changed line try_files $uri $uri/ /index.php?$args;
into try_files $uri $uri.html $uri/ =404;
.
As I understand the NGINX documentation, that should be enough, but instead of working links, when I click a note, my browser wants to download a file (without the extension). I guess there is another rule (higher in hierarchy) that forces to do something else when $uri
file is not found (instead of checking $uri.html
file).
See on my exemplary website https://example.do.lapy.pl/ - when you click on "note inside a folder" on left side, it downloads a file. As a note, when you adit the link into https://example.do.lapy.pl/folder/note-inside-a-folder.html
, it works.
Quartz author won't change this behavior in his generator -> https://github.com/jackyzha0/quartz/issues/591
Right now I'm achieving this on my own my_webapp
by:
Creating the folder posts/hello-world
and adding index.html
to it such -> posts/hello-world/index.html
instead of posts/hello-world.html
But it is of course an extra step per file unless you use an automated generator.
I actually think it's fairly standard practice outside of react or angular frameworks for paths like
/post/example-post
to go toexample-post.html
This is a part of the modern web, I think.
If you look at the url for this pull request, for example, it is
https://github.com/YunoHost-Apps/my_webapp_ynh/pull/76
without a file extension!_Originally posted by @NathanRussellUK in https://github.com/YunoHost-Apps/my_webapp_ynh/issues/76#issuecomment-1168559495_