Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Jekyll 404 page on GitHub Pages to fix case sensitive URLs
var allposts = [];
function redirectToCorrectPage() {
{% for post in site.posts %}
allposts.push("{{ site.url }}{{ post.url }}");
{% endfor %}
var url = window.location.toString();
if (url.slice(-1) === "/") {
url = url.slice(0, -1);
}
var allpostsUpperCase = allposts.map(function(value) {
return value.toUpperCase();
});
var i = allpostsUpperCase.indexOf(url.toUpperCase());
if (i != -1) {
console.log(allposts[i]);
window.location = allposts[i];
}
}
window.onload = redirectToCorrectPage;
@rohitnishad613

This comment has been minimized.

Copy link

@rohitnishad613 rohitnishad613 commented Oct 12, 2020

Where to load this script?

@sbliven

This comment has been minimized.

Copy link

@sbliven sbliven commented Nov 13, 2020

Add it to your 404.html page. Original blog: https://amreldib.com/blog/FixJekyllCaseSensitiveUrlsOnGitHubPages/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.