How to make the header animation on homepage different from anywhere else on the site

Solved

How to make the header animation on homepage different from anywhere else on the site

Viibed
Excursionist
23 0 5

I am designing my homepage and currently have my sticky header animation on "Only on scroll". But I want my sticky header on the homepage to be different from the rest of my site. I want the header on my homepage to be fixed at the top of the page and not have any animation, while keeping the other pages on my website WITH the "Only on scroll" animation. Here is my website: Viibed

 

Viibed_1-1722138602838.png

I want my header to be stationary at the top and have NO animation.

 

Need help, and thank you!

 

Accepted Solution (1)
BSS-TekLabs
Shopify Partner
2401 695 831

This is an accepted solution.

To make only the homepage not have a sticky header on scroll up, you can follow these steps:

1, Navigate to Online Store > Themes > Edit Code.

2, Locate and open the theme.liquid file.

3, Paste the code snippet provided below right before the closing head tag, then save your changes.

 

 

<script>
    document.addEventListener("DOMContentLoaded", function() {
        const currentURL = window.location.href;
        const targetURL = "https://viibed.myshopify.com/";
        if (currentURL === targetURL) {
            const headerElement = document.querySelector(".section-header.shopify-section-group-header-group");
            if (headerElement) {
                headerElement.style.position = "static";
            }
        }
    });
</script>

 

 

BSSTekLabs_0-1722046684147.png

We hope this assists in resolving the issue.

If you find our solution helpful, kindly consider Liking and Marking it as Accepted. Thank you!

 

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

View solution in original post

Replies 5 (5)

BSS-TekLabs
Shopify Partner
2401 695 831

Hi @Viibed,

Here are the steps you can follow:

1, Navigate to Online Store > Themes > Edit Code.

2, Locate and open the base.css (or theme.css, custom.css) file.

3, Paste the code snippet provided below at the bottom of the file, then save your changes.

sticky-header.header-wrapper {
    position: fixed;
    width: 100%;
}

Here is the result

BSSTekLabs_0-1722142095659.png

We hope this assists in resolving the issue.

If you find our solution helpful, kindly consider Liking and Marking it as Accepted. Thank you!

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now
Viibed
Excursionist
23 0 5

Not quite what I wanted, but I want it to have no animation like how the "None" setting does it and keeps it at the top of the page. I'll show it here.

Viibed_0-1722142799565.png

 

 

I want the HOMEPAGE header to have the "None" setting (no animation),

while every OTHER page has the "Scroll Up" animation.

Viibed_1-1722143104662.png

 

Thank you for willing to help me through this, I hope this clarified what I'm trying to do.

BSS-TekLabs
Shopify Partner
2401 695 831

This is an accepted solution.

To make only the homepage not have a sticky header on scroll up, you can follow these steps:

1, Navigate to Online Store > Themes > Edit Code.

2, Locate and open the theme.liquid file.

3, Paste the code snippet provided below right before the closing head tag, then save your changes.

 

 

<script>
    document.addEventListener("DOMContentLoaded", function() {
        const currentURL = window.location.href;
        const targetURL = "https://viibed.myshopify.com/";
        if (currentURL === targetURL) {
            const headerElement = document.querySelector(".section-header.shopify-section-group-header-group");
            if (headerElement) {
                headerElement.style.position = "static";
            }
        }
    });
</script>

 

 

BSSTekLabs_0-1722046684147.png

We hope this assists in resolving the issue.

If you find our solution helpful, kindly consider Liking and Marking it as Accepted. Thank you!

 

If our suggestions are useful, please let us know by giving it a like or marking it as a solution.


Salepify: Efficiently increase sales conversion with sale-driven features like auto add to cart, free gifts (free plan available)


Salemate: Boost your AVO with 2-layer offer, countdown upsell in your post purchase page


BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

BSSCommerce-HDL
Shopify Partner
2305 835 908

Hi @Viibed

Step 1: Go to Shopify Admin -> Online Store ->Theme -> Edit code

Step 2: Search file theme.liquid

Step 3: Insert this code above </head> tag: 

 

{% if template.name == 'index' %}
<style>
sticky-header.header-wrapper {
    position: fixed !important;
    width: 100% !important;
    top: 0;
    left: 0;
    z-index: 1;
}
</style>
{% endif %}

 

 

 

Hope this can help you,

If our suggestions are useful, please let us know by giving it a like or marking it as a solution. Thank you  😍

Sale banner, pop ups: Customize your sale banner, pop-ups and create countdown bar to boost conversion rate.
Simicart: Transform your Shopify store into a stunning and fully functional mobile app with just a few simple steps.
Product Labels & Badges:
Get more sales with striking labels, badges, and banners from our 10,000+ available templates.

BSS Commerce - Full-service eCommerce Agency | Use Shopify for 1$ in the first month now

Viibed
Excursionist
23 0 5

It worked! Thank you!