From Fedora Project Wiki
From finally-working-mediawiki-sitemap
Finally a working mediawiki sitemap
Lonny's picture
Sun, 08/24/2008 - 03:46 — Lonny
This is a follow up to Making a sitemap (opensource documentation wild goose chase).
So, thanks to the OLPC folks, we finally have a working google-compliant sitemap.
The code below is adapted from http://wiki.laptop.org/go/SEO_for_the_OLPC_wiki/sitemapgen.
Here are some notes about the implementation:
1. Save the code as makesitemap.sh on the root directory (appropedia.org/)
2. Add executing permissions to the file, by typing chmod u+x makesitemap.sh
3. Run it from the site root by typing sh makesitemap.sh, or even better run using cron.
4. I had to download a new version of generatesitemap.php from
http://www.mediawiki.org/wiki/Manual:GenerateSitemap.php.
I was getting a Class 'MWNamespace' error.
5. I had to get rid of the ticks on the echo lines that were present in the OLPC version.
They were breaking the echo.
----makesitemap.sh----
#!/bin/sh
echo Sitemap script ...
cd maintenance/
/usr/local/php5/bin/php generateSitemap.php
echo Sitemap script ... done
echo Moving files, ungzing ...
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-appropedia-w1-NS_*.xml > sitemap.xml
echo Cating all of the name spaces ... done
echo Replacing "localhost" with www.appropedia.org ...
sed -i 's,localhost,www.appropedia.org,g' sitemap.xml
echo Replacing "localhost" with www.appropedia.org ... 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 "" >> sitemap.xml
sed -i '1i\
<?xml version="1.0" encoding="UTF-8"?>\
' sitemap.xml
echo Adding the XML headers back... done
echo Cleaning up the catd files ...
rm sitemap-appropedia-w1-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://www.appropedi...
wget -q -O /dev/null http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=http://w...
wget -q -O /dev/null http://submissions.ask.com/ping?sitemap=http://www.appropedia.org/sitema...
wget -q -O /dev/null http://api.moreover.com/ping?u=http://www.appropedia.org/sitemap.xml
wget -q -O /dev/null http://webmaster.live.com/ping.aspx?siteMap=http://www.appropedia.org/si...
echo Pinging the sitemap update to the search engines... done
echo All done
----
Please feel free to ask questions. I hope that this is finally fixed right.
* wiki tech
* Lonny's blog
could work, could't test it myself though.... nippur 01:24, 24 January 2009 (UTC)
