Shopify themes, liquid, logos, and UX
I recently put in some code for my website to load further down the page so my homepage image could be instantly shown. I soon realized that it also did it for every single page on my website. I only want it to start further down on the homepage, and not any other page.
Here's where the other pages start.
I can paste the code I am using now, (this code is located in theme.liquid above the </body> tag)
<script>
window.scrollTo({
top: 500,
left: 0,
behavior: 'smooth'
});
</script>
I only want this code to work ONLY on my homepage, and not any other page. Here is my website: Viibed
Please help, and thank you!
Solved! Go to the solution
This is an accepted solution.
Hi @Viibed
{% if template == 'index' %}
<script>
window.scrollTo({ top: 500, left: 0, behavior: 'smooth' });
</script>
{% endif %}
This is an accepted solution.
Hi @Viibed
{% if template == 'index' %}
<script>
window.scrollTo({ top: 500, left: 0, behavior: 'smooth' });
</script>
{% endif %}
Do I replace the original code with this?
Yes, exactly.
Worked, thank you!
June brought summer energy to our community. Members jumped in with solutions, clicked ...
By JasonH Jun 5, 2025Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025