SEO for the OLPC wiki/sitemapgen

From OLPC
< SEO for the OLPC wiki
Revision as of 02:02, 27 August 2008 by Sethwoodworth (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

This is a script, that when run in the /maintainence folder of mediawiki, will:

  1. Use Mediawiki's built-in sitemapgenerator script
  2. Cat all of the files from each name space
  3. Change the URL's to match the wiki naming scheme
  4. Ping google, etc. that this has been done


#!/bin/sh
echo Sitemap script ...
cd /home/www/wiki.laptop.org/maintenance/
php-cgi generateSitemap.php
echo Sitemap script ... done

echo Moving files, un'gz'ing ...
mv -f *.gz ../
cd ..
gzip -d *.xml.gz
echo Moving files, un'gz'ing ... done

echo Archiving old sitemap...
mv sitemap.xml sitemap.xml.$(date "+%Y%m%d%H")
echo Archiving old sitemap... done

echo Cating all of the name spaces ...
cat sitemap-wikidb-NS_*.xml > sitemap.xml
echo Cating all of the name spaces ... done


echo Replacing localhost with wiki.l.o ...
sed -i 's,localhost,wiki.laptop.org,g' sitemap.xml
echo Replacing localhost with wiki.l.o ... done

echo Cleaning that up ...
sed -i "/?xml version/d" sitemap.xml
sed -i "/urlset/d" sitemap.xml
echo Cleaning that up ... done

echo Adding the XML headers back...
echo "</urlset>" >> sitemap.xml
sed -i '1i\
<?xml version="1.0" encoding="UTF-8"?>\
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' sitemap.xml
echo Adding the XML headers back... done

echo Cleaning up the catd files ...
rm sitemap-wikidb-NS*
echo Cleaning up the catd files ... done

echo Pinging the sitemap update to the search engines...
wget -q -O /dev/null http://www.google.com/webmasters/tools/ping?sitemap=http://wiki.laptop.org/sitemap.xml
wget -q -O /dev/null http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=http://wiki.laptop.org/site$
wget -q -O /dev/null http://submissions.ask.com/ping?sitemap=http://wiki.laptop.org/sitemap.xml
wget -q -O /dev/null http://api.moreover.com/ping?u=http://wiki.laptop.org/sitemap.xml
wget -q -O /dev/null http://webmaster.live.com/ping.aspx?siteMap=http://wiki.laptop.org/sitemap.xml
echo Pinging the sitemap update to the search engines... done


echo All done

Use

The guys over at Appropedia are using this script over at their wiki as well: