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

Topic summary

A Shopify store owner wants to redirect their “About Us” main menu link to a specific homepage section while preserving the original URL (www.mydomain.com/page/about-us) instead of showing a section ID.

Proposed Solution:

  • Add JavaScript code that intercepts clicks on the menu item
  • Uses scrollIntoView() with smooth scrolling behavior to navigate to the target section
  • Prevents default link behavior while maintaining the URL

Important Consideration:

  • The section ID (e.g., #shopify-section-template--21767037190437__c79ece61-6edd-4d33-be74-12b06c1d5534) will change if the section is removed and re-added
  • The JavaScript code must be updated with the new section ID whenever this occurs
  • Code snippets and reference IDs were provided for implementation

Status: Solution provided but requires manual maintenance if section structure changes.

Summarized with AI on November 11. AI used: claude-sonnet-4-5-20250929.

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

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.