NewStrategy — expert-reviewed growth plan for AI searchLearn more

JavaScript Menus: Why AI Assistants Can't Follow Them

An assistant arrives at your homepage, reads it, then looks for links to everything else you have.

How this works

If your menu is built by JavaScript rather than made of real links, it finds nothing. The visit ends on the homepage. Everything behind the menu still exists, it just never gets visited.

A real link looks like this in the page's code:

Page source
<a href="/services">Services</a>

A JavaScript menu often looks like this instead:

Page source
<div onclick="goToPage('services')">Services</div>

Both behave identically for a person with a mouse. Only the first one is a path a crawler can follow. Google's guidance on crawlable links says the same: an <a> element with an href attribute, or it isn't a link.

Why it matters

Your homepage is usually the only page an assistant knows about to begin with. The menu is how it discovers the rest. Break that and your site is effectively one page, and it's the page that says the least about what you actually sell.

This hits service businesses hardest. The homepage says who you are; the services pages say what you do and what it costs. Those are the pages that answer real questions, and they're exactly the ones behind the menu.

How to fix

1. Check what your menu is made of. Open your homepage, press Ctrl+U (Cmd+U on a Mac) to view the source, and look for your menu item names. If you see them inside <a href="...">, you're fine. If they appear inside <div> or <button> with no href nearby, or don't appear in the source at all, the menu is built by scripts.

2. Switch the main menu to standard links. In most themes and page builders this is a setting, not a rebuild: look for options named along the lines of AJAX navigation, dynamic menu or JavaScript-only navigation, and turn them off for the primary menu.

3. Give yourself a second path anyway. Even with a working menu, a sitemap lists your pages directly rather than making anyone find them. The two together are much more reliable than either alone.

4. Check again in the source after publishing. The menu items should now be plain links.

Where to change this on your platform

WordPress

this depends on your theme and page builder rather than on WordPress itself. Build the primary menu with the built-in menu tool and real page links, and turn off any "AJAX navigation" option your theme offers.

Shopify

standard navigation in Shopify produces real links; the risk comes from custom themes and menu apps.

Wix and Squarespace

the built-in menus produce real links. If your navigation is a custom-coded block or an embedded element, that's where to look.

If you can't change it

If your navigation is locked by the theme and you can't replace it, make sure a sitemap is published and listed in your robots.txt. It won't fix the navigation, but it gives assistants a complete list of your pages anyway.

Check how AI assistants see your site

See which assistants can reach your site and what's getting in the way.

No credit card needed ✦ 14-day trial on all plans