How can I redirect a main menu to a specific homepage section while keeping the original URL?

How can I redirect a main menu to a specific homepage section while keeping the original URL?

Chaychay341235
Shopify Partner
29 0 2

Hello everyone, i need some help with my store. I want to redirect my main menu named 'About Us" to a specific section in my homepage but i want to remain the url to www.mydomain.com/page/aboutus instead of the id of specific shopify section. Can anyone help?  I want to redirect it in this section below.

 

Shopify name url: www.ravinginbox.com

 

screenbud-d3301842-b4c8-4614-a505-e4d89ab805f2.png

Reply 1 (1)

prakashVt
Shopify Partner
260 23 35

Add this code to your JS file and it will work.

document.querySelector("#HeaderMenu-about-us").addEventListener("click",(e)=>{
e.preventDefault();
     document.querySelector("#shopify-section-template--21767037190437__c79ece61-6edd-4d33-be74-12b06c1d5534").scrollIntoView({ behavior: 'smooth' });
})

  Please keep in mind that if you remove the "about us" section from your website and add it back again, the ID of the section will change. This means that you will need to update the "shopify-section-template--21767037190437__c79ece61-6edd-4d33-be74-12b06c1d5534" to the new ID. I have included the current ID for your reference.

prakashVt_0-1709789344808.png

 

- Enhanced your Cart Drawer for free, Shipping Protection included -VTN Cart Drawer Pro
- Feel free to Contact for more help (Free Support): prakash.prabhakar@vtnetzwelt.com