Categories navigation menu with consistent urls

One of my problems with TXP is the section sensitive way categories are handled. The <txp:category_list /> tag returns a different URL depending on the page you are on.

This category based navigation method returns a list of categories which contain articles (empty categories are excluded) but it also returns the same url for the category every time, which in my opinion is better for SEO.

The page template code

<ul id="categorylist" class="list">
<li><a href="<txp:site_url />">Home</a></li>
<txp:category_list break="" exclude="somecategory,someothercategory">
<txp:variable name="hasarticles" value='<txp:article_custom category=''<txp:category />'' limit="1" />' />
<txp:if_variable name="hasarticles" value="">
<txp:else />
<li><txp:category title="1" link="1" section="default" /></li>
</txp:category_list>
</txp:if_variable>
</ul>

There is a forum thread with further discussion on this topic.

Thanks to Els for her assistance in drafting and refining this code.

comments powered by Disqus