Underscores to dashes in MediaWiki (not yet)

It's clear that dashes (-) are better than underscores (_) for search engine optimization. So people have looked for ways to make MediaWiki use -. Wikihow is one of the few MediaWiki sites that behaves this way, but unfortunately even they don't seem to be running an extension for this. I tried my luck at changing the MediaWiki core (Title.php) but I'll leave this for now. I can just tell that replacing all occurrances of '_' with '-' doesn't cut it - but probably only because this also changes the way wiki articles are stored in the database. One or two extended MySQL queries might fix that. I'll try that another day.

Comments

Keep working on it Kasper!

Keep working on it Kasper! I'm looking into it as well, I think a lot of people out there would be interested.

Thanks for the encouragement

Thanks for the encouragement Sam. I have a very crude solution, now up at wikifurniture.org.

I turned the last line of getLocalUrl into:

return str_replace('_', '-', $url);

And in my nginx configuration I added the following line, 10 times:

rewrite (.*)-(.*) $1_$2;

This is a mediocre solution but I yet haven't found the right place to turn '-' into '_' for the title used in the MySQL query. I also wonder if it's actually possible to turn this into an extension at all. Of course, help or suggestions are very welcome.

Links with spaces are redirected into dashed links, but this is not yet happening to links with underscores.

The blog post is from 2005 -

The blog post is from 2005 - is this still up to date?

For sure some people at Google know about Wikipedia, and I would not be surprised if their algorithms have become more underscore-friendly since then.

I would always prefer dashes for readability in the browser address bar, though.

Crude solution - Looks like

Crude solution - Looks like it's all working on your wikifurniture.org site now Kasper? I done a simple 'find and replace' in one of the files, (cant remember which now) and it worked for me.

@lemon-head
Good point lemon head, I think I read somewhere recently that they've changed the algorithms in regard to underscore, but yes it looks better if nothing else now : )

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options

By submitting this form, you accept the Mollom privacy policy.