Anchor menu item links invalid on page 404

Hi,

My web site is built with a landing page and a 404 page. The landing page is divided in few sections. The menu refers to them using anchor link using the format #something. It works great on the landing page but I have just noticed an unexpected behavior form the 404 page.

To reach the 404 page I type an invalid link like http://agilomedia.com/jladksfjak. Now all the links in the menu are built/prefixed with this invalid target jladksfjak. For example the contact page link is http://agilomedia.com/jladksfjak#contact instead of http://agilomedia.com/#contact

Would it be too much trouble to clarify my understanding on the correct way to set the menu so it works for the 404 page?

Thanks!

Hi @shimoda,

You need to create another menu under Appearance > Menus and set it as your primary menu(default menu).
It should be exactly the same as your onepage menu but the links should have full urls.

For example

Stratégies should link to http://agilomedia.com/#strategies and not just #strategies
Conception should link to https://agilomedia.com/#conception and not just #conception

Hope this helps

Hi @paul.r,

Thank for your solution!
Would it be too much to challenge you a little more?

I have a test site test.vifranc.com and the production site vifranc.com. Modifications are done test.vifranc.com before been pushed to the production site.

I believe that the solution you propose will not work on both sites without editing the menu links. Would there be a solution where links be relative to the domain?

Hi @shimoda,

I recommending using absolute URL as much as possible, relative URL should be the case to case basis only like hashes that link on the same page. And Wordpress works on absolute URL that’s why it has functions that let you utilize it. So yes, you’ll have to edit your site’s URL added in the menu every time you migrate your site to different URLs.

Some migration tools do it automatically, unless you’re doing manual database migration. I recommend using tools when migrating, like All in one migration plugin, it will change the URLs for you :slight_smile:

Thanks!

Thanks @Rad!

You’re more than welcome, glad we could help.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.