Skip to content

Instantly share code, notes, and snippets.

@mayurah
Last active March 26, 2017 23:09
Show Gist options
  • Save mayurah/4a0861b6d68b335d970e01e9fff4bd6e to your computer and use it in GitHub Desktop.
Save mayurah/4a0861b6d68b335d970e01e9fff4bd6e to your computer and use it in GitHub Desktop.
blogspot to shopify redirect (javascript way)
// Tested on friend Dr Raley's website
// Old (Google Blogger / Blogspot): http://cecileraleydesigns.blogspot.com/
// New (Shopify): https://www.cecileraleydesigns.com/blogs/cecile-raley-designs/
// Note: This simple JS only redirects blog (containing month/day) and not home page, or dedicated pages.
var newBlog = "https://www.your-website.com/blogs/blog-name/";
var current_blogspot_slug = document.baseURI.split("/")[5].split(".")[0];
if( document.baseURI.split("/")[3] % 1 === 0 ) if( document.baseURI.split("/")[4] % 1 === 0 ) {
console.log("true - let's redirect to new home");
window.location.href=newBlog+current_blogspot_slug;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment