SEO for the OLPC wiki/sitemapgen

From OLPC
Jump to: navigation, 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 Cat'ing all of the name spaces ...
cat sitemap-wikidb-NS_*.xml > sitemap.xml
echo Cat'ing 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 cat'd files ...
rm sitemap-wikidb-NS*
echo Cleaning up the cat'd 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