Changing navigation menu when on a different page

i need help changing the navigation menu link and title from about-us to home when the user is on the about-us page. i have tried editing the code in header-mega-menu.liquid and header.liquid. i have tried to use an if statement to change the navigation menu depending on the page and i also tried to have 1 navigation menu with 2 button links and make one visible and the other display: none; depending on the handle page. both methods did not work.

i am new to liquid and i am not sure what i am doing wrong, below are the two methods i have used to do this, if there is anything i am doing wrong, please let me know.

(method 1)

{% comment %} Renders a megamenu for the header. Usage: {% render ‘header-mega-menu’ %} {% endcomment %} {% comment %} Debug output {% endcomment %} {% if page.handle == ‘about-us’ %} {% assign [menu_to_render] = ‘header2’ %} {% else %} {% assign [menu_to_render] = ‘header1’ %} {% endif %}

(method 2)

    {%- for link in section.settings[menu_to_render].links -%} {% assign link_visibility = 'visible' %} {% if page.handle == 'about-us' and link.title == 'Home' %} {% assign link_visibility = 'hidden' %} {% elsif page.handle != 'about-us' and link.title == 'About Us' %} {% assign link_visibility = 'hidden' %} {% endif %}
  • {%- endfor -%}

li.hidden {
display: none;
}