321 SEO Team

Make WP_Nav_Menu SEO Friendly

wp_nav_header - Insert header tagsBy default WordPress gives your navigation menus, though every item inside is not wrapped in anything special. The structure is this:

<div><ul><li><a>Menu item</a></li></ul></div>

Nothing special, but good for organization.

If you understand the basic Search Engine Optimization (SEO) standards then you know that search engines love Header Tags. Header tags are those HTML tags that rank 1 – 6, the lowest being the most significant… and yes, there are only 6 available with no rumors of more in the future (that I’m aware of).

<h1><h2><h3><h4><h5><h6>

For most of the sites I build in WordPress I like to insert <h2> or <h3> around every list item in my navigation menu. To do that it’s pretty easy, though assuming you didn’t design your theme you’ll have to track down where your nav menu is called. If it’s at the top of your website, then it may be in the header.php, but if it’s on the side then you may find it in your sidebar.php. Regardless, navigating through theme files is a whole different topic and depending on who designed it that could be extremely easy or a bit of work.

If there is no additional code then added by the theme designer (often isn’t) then your code will look like the following:

<?php wp_nav_menu(array('menu' => 'Menu Name')); ?>

Note that ‘Menu Name’ is definitely going to be different. Also, some themes call a category listing instead of a menu, which can make adding menu items easier for beginner users – this is extremely limiting and not recommended. There are a few different category list calls, but typically the code will look similar to the one above, only replace wp_nav_menu with wp_list_categories or something like that. If that’s the case you can go through a process of replacing the category list with the nav menu, though after you do so you will also need to (1) declare the nav menu in your functions.php and then call it forward in your WordPress admin back-end area (Appearance / Menus).

To add the header tags you’ll want to add two new lines inside the array(), which will look like the following when completed:

<?php wp_nav_menu(array('menu' => 'Menu Name', 'before' => '<h2>', 'after' = '</h2>')); ?>

If your site is new you won’t notice much change, but if it’s been around then you should notice some significant recognition changes from Google and other search engines. You can monitor this change very easily with Google Webmaster Tools.


January 20, 2012

Category: WordPress

Tags: , ,

Leave a Reply