SEO solution using autopath and tokens
Problem: In order to improve SEO for our blogs site, http://blogs.familyeducation.com/parenting, it was decided that content should include the gender of the blogger, in the form of moms or dads.
http://blogs.familyeducation.com/parenting
Solution: I decided to extend pathauto by adding a new token [blogger-type] I also created two new roles "moms" and "dads" by assigning the appropriate role to each of our bloggers I could then configure pathauto to add the appropriate path to each bloggers posts for example:
Before:
http://blogs.familyeducation.com/blogs/aliki-mcelreath/books-books-books
After:
http://blogs.familyeducation.com/parenting/moms/aliki-mcelreath/books-bo...
note: 'parenting' was a static part of the url added to both moms and dads blog posts.
Here is a step-by-step of how I implemented this solution
1) on /admin/user/roles add roles: moms, dads
2) Edit bloggers profiles, added role of moms or dads accordingly.
3*) Modified modules/pathauto/pathauto.module
added new token [blogger-type]
4) Changed path for blog entries, bloggers main blog page in pathauto admin settings.
Blog path settings -> Patternn for blog page paths:
parenting/[blogger-type]/[user-raw]
Node Path settings -> Pattern for all blog entry paths:
parenting/[blogger-type]/[author-name-raw]/[title-raw]
* This step has been done via coding changes to pathauto.module
5) Change existing content paths in url_alias table to reflect new paths. Note this is done in MySQL comand line, but you can do the same using PHPMyAdmin if you wish.
create temp tables for each moms, dads:
mysql> create table momsnodes as select nid, uid, concat("node/",nid) as src from node where uid=5807;
Query OK, 193 rows affected (0.01 sec)
Records: 193 Duplicates: 0 Warnings: 0
mysql> create table dadsnodes as select nid, uid, concat("node/",nid) as src from node where uid=5845;
Query OK, 135 rows affected (0.01 sec)
Records: 135 Duplicates: 0 Warnings: 0
check to make sure same amount of nodes represented in the url_alias table:
Use script to change blog entries dst field in url_alias table:
sites/familyeducation.com/blognodeupdate.php
<?php
$link = mysql_connect('localhost', 'drupal', 'password');
if (!$link) {
die('Could not connect: ' . mysql_error());
}
echo 'Connected successfully';
if (!mysql_select_db('drupal_feforum', $link)) {
echo 'Could not select drupal_feforum database';
exit;
}
$sql = "SELECT src FROM dadsnodes";
$result = mysql_query($sql, $link);
while ($row = mysql_fetch_assoc($result)) {
$sql2="UPDATE url_alias SET dst =
REPLACE(dst, 'blogs/', 'parenting/dads/') WHERE
src = '". $row['src'] ."'";
$result2 = mysql_query($sql2, $link);
}
?>
There were many other site specific theming changes that needed to be made to get this site to work properly. Lesson learned, it's always easier to decide on the path structure before you have lots of content that has to be retro actively changed.
- Tags:

