I’ve currently got a portfolio website made here on Webflow that I like to export out to my personal domain name. I’ve opted to remove the “.HTML” from my URL and force users to my HTTPS domain with my .HTACCESS file. I noticed recently that it disables my “Current” state in my navigation, which I feel is important for users on my website.
I’ll take any help I can get!
I host a few Webflow generated sites with Netlify and had the same issue. I couldn’t find an elegant way around it so had to write a custom script to change all the hrefs within the page. I have this in the body code globally.
<script>
var links = document.querySelectorAll('a');
links.forEach(function (link) {
var existingHref = link.href;
if (existingHref.includes('index.html')) {
var newHref = existingHref.substring(0, existingHref.lastIndexOf('/'));
link.href = newHref;
} else if (existingHref.includes('.html')) {
var newHref = existingHref.substring(0, existingHref.lastIndexOf('.'));
link.href = newHref;
}
});
</script>
Jason, thank you for the quick reply. Now I would imagine I’d have to remove my .htaccess file for this to work? Or that should not matter. I just wouldn’t want these two to conflict with each other.
I don’t think it would make much difference, but I’m not 100% sure so you would need to test it. The script above alters the href values for all the links on the page and removes any .html that it finds.
Jason, your solution worked with removing the .html, but the post found here solved my specific issue with the css class “.w–current” within my navigation bar:
This solution remove text-align: left from mobile menu on current state.
If you have align left items on mobile menu, current one will be text-align center.
I’m looking for best solution still. I will test jasondark way now.