
When you create a new page in concrete5, by default the Page Alias (what the URL for that page will be) uses underscores to separate words. For example, if you were to create a new page titled Contact Us, concrete5 would automatically give that a Page Alias of contact_us. Now, from an SEO (Search Engine Optimization) standpoint, Google themselves recommend using hyphens instead of underscores in your URLs. Matt Cutts from Google says:
“So if you have a url like word1_word2, Google will only return that page if the user searches for word1_word2 (which almost never happens). If you have a url like word1-word2, that page can be returned for the searches word1, word2, and even ‘word1 word2′.
So, instead of having to manually change the underscores to hyphens in the Page Alias box every time we create a new page, we can just change the file that controls that. The file we need to change is collection_add.php which is located in the /concrete/elements folder. (Now technically, we should just be able to place the modified collection_add.php file in the /elements folder within the root of our concrete5 installation and it is supposed to override the one within the /concrete/elements folder, but for some reason this doesn’t work – so we have to change the file in the core.)
First, make a backup of collection_add.php in case anything goes wrong – so you can revert back to it. (Remember, since we are changing a core file, when you go to upgrade concrete5 you will need to make this change again.)
Now, all we need to edit in collection_add.php are lines 7-9. We need to replace the _ with -. So, find this code:
alias = alias.replace(/[\s|.]+/gi, "_"); alias = alias.replace(/[^0-9A-Za-z-]/gi, "_"); alias = alias.replace(/--/gi, '_');
And replace it with this:
alias = alias.replace(/[\s|.]+/gi, "-"); alias = alias.replace(/[^0-9A-Za-z-]/gi, "-"); alias = alias.replace(/--/gi, '-');
That should be it – now every time you create a page, the Page Alias will automatically use hyphens instead of underscores.


Great tip, and great site, added to RSS.
Important info on SE. Thanks.
Be blessed.
Isyaias
Thanks for the tip. I really like your works.
May God blissed you and your family greatly brother.
@ymne – Thank you! You too!
Swedish chars – ÅÄÖ åäö
add the lines:
alias = alias.replace(/[\u00D6\u00F6]/gi, ‘o’);
alias = alias.replace(/[\u00E5\u00C5\u00C4\u00E4]/gi, ‘a’);
Thanks for the tip /mattias
So, to get some really basic SEO feature, like hyphens in URLs one has to basically hack core files? That is a real downer to me, who’s looking into Concrete5…
Oliver, this is actually old – the latest version of concrete5 now includes hyphens between words instead of underscores