Use the "Custom Content" section in a debut theme to add a code block with the contents of shopify-redirect.js
. This will allow you to create a user-editable redirect. The code is wrapped in an iFrame check so the redirect is not triggered while in the editor. Editors can toggle the redirect on/off by showing/hiding that section.
Last active
August 4, 2020 22:24
-
-
Save jongacnik/cc339f2b36b88cc87cd8a09985bc87ea to your computer and use it in GitHub Desktop.
Shopify Homepage Redirect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function inIframe () { | |
try { | |
return window.self !== window.top; | |
} catch (e) { | |
return true; | |
} | |
} | |
if (!inIframe()) { | |
window.location.replace('/collections/all') | |
} else { | |
if (document.currentScript) { | |
var script = document.currentScript | |
script.parentNode.innerHTML = '<p>This page redirects to <code>/collections/all</code>. To disable the redirect, hide the "Custom Content" section.</p>' | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment