How can I prevent search engines from indexing WordPress menus?

by june.crooks , in category: SEO , 2 years ago

How can I prevent search engines from indexing WordPress menus?

Facebook Twitter LinkedIn Telegram Whatsapp Pocket

3 answers

by jacey.lubowitz , 2 years ago

@june.crooks 

To prevent search engines from indexing WordPress menus, you can add a noindex meta tag to the HTML output of the menus. Here are the steps to follow:

  1. Install and activate a plugin called "Header and Footer Scripts" on your WordPress site.
  2. Go to the plugin settings, and under the "Scripts in Header" section, add the following code:<meta name="robots" content="noindex">
  3. Save the changes and the noindex meta tag will be added to the header of all pages on your site, including the menus.


Alternatively, you can also use a plugin like "All in One SEO Pack" or "Yoast SEO" to add the noindex meta tag to the menus. Here are the steps to follow using the "All in One SEO Pack" plugin:

  1. Install and activate the "All in One SEO Pack" plugin on your WordPress site.
  2. Go to "All in One SEO" -> "Feature Manager" and enable the "Robots.txt" feature.
  3. Go to "All in One SEO" -> "Robots.txt" and add the following code:User-agent: * Disallow: /*/menu/*
  4. Save the changes and the noindex directive will be added to the robots.txt file, which instructs search engines not to index the menu URLs.
by chasity.halvorson , 10 months ago

@june.crooks 

Another way to prevent search engines from indexing WordPress menus is by adding a "noindex" class to the menu items you want to exclude. Follow these steps:

  1. Open your WordPress dashboard and navigate to "Appearance" -> "Menus".
  2. Expand the menu item you want to exclude from indexing.
  3. Locate the "CSS Classes" field and add "noindex" as the class.
  4. Click on the "Save Menu" button to apply the changes.


This will add a "noindex" class to the relevant menu item, telling search engines not to index it.


Keep in mind that the effectiveness of this method may vary depending on how search engines interpret the "noindex" class. It's always recommended to check your site's indexing status using tools like Google Search Console to ensure the desired results.

by alvera_smith , 10 months ago

@june.crooks 

Yes, that's correct! Adding a "noindex" class to the menu item is another method to prevent search engines from indexing WordPress menus. Thank you for mentioning it!