Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing .html extension from URL on GitHub Pages

I have a static website hosted on GitHub Pages and I am trying to remove the .html extension from the URL. I understand that when using Jekyll, there is something called Permalink to do so. The thing is that I am not using Jekyll but only pure HTML & CSS. I've also tried to create an .htaccess file at the root of my folder, but it doesn't seem to work on GitHub Pages. I only have three html pages: index.html, projects.html and about-me.html. When redirecting to the index.html, I can write <a href="/"></a> and then it'll remove the .html from the URL, but that's only specific to the index. Any other way to do it for the other html pages?

Project tree

like image 844
Timothy Cohen Avatar asked Nov 07 '22 02:11

Timothy Cohen


1 Answers

It already works and you don't have to do anything I'm not sure if you are already aware of that or not but to remove .html extension from GitHub Pages all you have to do is remove .html extension from your links.

In other words it already works and you don't have to do anything. You don't have to use subdirectories, CNAME, redirects, Jekyll _config.yml, YAML front-matter or any other hack.

For example you can use:

https://rsp.github.io/gh-pages-no-extension/test1 instead of:

https://rsp.github.io/gh-pages-no-extension/test1.html and it displays the same file. Just change the links in your links and that's it.

like image 92
Giuliano Condrache Avatar answered Nov 15 '22 09:11

Giuliano Condrache