Topic on Project:Support desk

How to remove Category Links but keep their Functionality?

4
Holygamer (talkcontribs)

My Versions: MediaWiki: 1.16.5, PHP: 5.2.17, MySQL: 5.1.61

Basically I don't like the way MediaWiki displays categories. The page name looks ugly like this: "Category:List of Playstation Games" instead of this "List of Playstation Games". Also I don't like the way categories are displayed, they are displayed in columns which doesn't allow long page names to display on 1 line.

I prefer to create a page with any name I want and then use the Nice Category List extension to show all the pages tagged with a category so I get a list like this:

  • Page 1
  • Page 2

Unfortunately in articles I then have lots of links to useless category pages which I don't want as I've added tags to the articles. Is there any way to keep the functionality of the tags but to not have the Category links display at the bottom of articles as it's hurtful to Search Engine Optimization? I know I can hide them with CSS but the search engines still see the links.

Bawolff (talkcontribs)

Note: A page's name can be changed using displaytitle if $wgRestrictDisplayTitle is set to false. Note, that the format of a category page can be customized by extensions (of course that would actually require someone to write an extension that meets your needs).


In order to remove the list of categories the current page is in from the bottom of a page, put the following at the bottom of LocalSettings.php (note: only tested on svn [1.20alpha], so ymmv. If it doesn't work let me know).

$wgHooks['OutputPageMakeCategoryLinks'][] = 'wfKillCatLinks';
function wfKillCatLinks( $out, $categories, &$catLinks ) {
                        global $wgContLang;
                        #Stops categorylinks from appearing at bottom of page
                        foreach ( $categories as $category => $type ) {
                                $origcategory = $category;
                                $title = Title::makeTitleSafe( NS_CATEGORY, $category );
                                $wgContLang->findVariantLink( $category, $title, true );
                                if ( $category != $origcategory ) {
                                        if ( array_key_exists( $category, $categories ) ) {
                                                continue;
                                        }
                                }
                                #this part is still needed so that
                                # js can see what categories are on a page
                                $out->mCategories[] = $title->getText();
                        }
           return false;
            }


p.s. I still think that SEO is a bunch of hocus pocus, and this stuff doesn't really matter.

Holygamer (talkcontribs)

Thank you very much. It works. SEO doesn't matter for big sites such as Wikipedia but for individuals with their own site, I promise you SEO isn't hocus pocus! If an article page has several links to categories or other useless pages it means that page as well as all the other important pages such as your homepage have less PageRank. If your homepage has less PageRank then it won't appear as high in Google search results. And if people can't find my site then nobody will visit it!

I also used to use Extension:DynamicTabs so that useless pages (SEO wise) such as the talk, edit, history, etc tabs would not show to people who aren't logged in. However it doens't work on the Vector skin. I don't suppose you know anyone that could update it to work with the Vector skin do you? Thanks again.

Subfader (talkcontribs)

"If an article page has several links to categories or other useless pages it means that page as well as all the other important pages such as your homepage have less PageRank. If your homepage has less PageRank then it won't appear as high in Google search results. And if people can't find my site then nobody will visit it!"

That's a problem with Google & co, not MW. SEO = search engine manipulation = destroying proper webdesign.

Reply to "How to remove Category Links but keep their Functionality?"