brotherhood of LAN

msg:4240097 | 2:18 pm on Dec 8, 2010 (gmt 0) |
The link you posted does a fine job of creating an XML sitemap, for small sites. The online tools are limited/slow because they have to crawl your site to find links and rely on the presence of a last modification header to add that data to the sitemap. If you have experience with a server-side language you can generate/manage your sitemap using that. PHP has some handy XML functions to manipulate XML. When you have a very large site, you will need to make sitemap index files. This is a good read to familiarise yourself with site maps: [sitemaps.org...] Below is a very simple PHP script I made to manage an XML sitemap. It creates an MD5 of the URL so entries can quickly be found when requiring an edit. I edited slightly but it should work as is.
<?php
class sitemap { public function __construct() { if(!is_file('Sitemap.xml')) { fopen('Sitemap.xml','a'); fclose($fp); $this->generate(); } } public function load() { global $dom; $dom = new DOMDocument; $dom->preserveWhiteSpace = true; $dom->loadXML(file_get_contents('Sitemap.xml')); } public function generate($flag) { global $categories,$dom,$urlset; $dom = new DOMDocument(); $dom->loadXML('<?xml version="1.0" encoding="UTF-8"?> <urlset xml:ns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> </urlset>');
$urlset = $dom->getElementsByTagName('urlset')->item(0); // Example adding of home page $this->add_url(array('loc'=>'http://'.$_SERVER['SERVER_NAME'].'/')); // Iterate through the rest of your known website URLs here and apply this function // $array contains key=>value pairs to add to the sitemap where 'key' is a tag and 'value' is its contents $this->add_url($array); $dom->save('Sitemap.xml'); } public function add_url($vars) { global $dom,$urlset; if(!isset($urlset)) $urlset = $dom->getElementsByTagName('urlset')->item(0); $node = $dom->createElement('url'); $node->setAttribute('id',md5($vars['loc'])); foreach($vars as $key => $var) { $node2 = $dom->createElement($key); $node3 = $dom->createTextNode($var); $node2->appendChild($node3); $node->appendChild($node2); } $newnode = $urlset->appendChild($node); $vars['md5'] = md5($vars['loc']); } public function editlastmoddate($id) { global $dom; $xpath = new DOMXPath($dom); $mod = $xpath->query("/urlset/url[@id='$id']/lastmod"); $mod->item(0)->nodeValue = strftime("%Y-%m-%d",time() - gmmktime() + mktime()); $dom->save('Sitemap.xml'); } public function deleterow($id) { global $dom; $xpath = new DOMXPath($dom); $urlset = $dom->getElementsByTagName('urlset')->item(0); $row = $xpath->query("/urlset/url[@id='$id']")->item(0); if($row) $row->parentNode->removeChild($row); $dom->save('Sitemap.xml'); } }
?>
|
Mark_A

msg:4240447 | 9:03 am on Dec 9, 2010 (gmt 0) |
Hi brotherhood of LAN thanks for that. Not completely sure I understand it :-) Actually, wondering if I really need a sitemap. My sites are pretty straightforward and all the pages are easily found by crawling. All the pages I want to be found that is.
|
piatkow

msg:4240508 | 12:00 pm on Dec 9, 2010 (gmt 0) |
I found a sitemap a benefit. For a small, reasonably static, site its easy enough to create in a standard text editor.
|
OMZen

msg:4240843 | 6:27 am on Dec 10, 2010 (gmt 0) |
1) For small sites (<500 pages), you can use the site mentioned in your original post. For bigger sites, you can download free app like GSitecrawler to generate XML or txt sitemaps For CMS like wordpress there are readymade sitemap plugins to generate XML or HTML sitemaps. 2) Having sitemap aids in crawl discovery, but for small sites with good IA, bots can find all URL's without need for sitemap. However it's a good practice to have one to discover any potential issues. 3) Nothing wrong if you are already using html sitemap and all pages are getting crawled without issues.
|
spiritparse

msg:4259840 | 8:50 am on Jan 29, 2011 (gmt 0) |
If you have a large website you can try GSiteCrawler (free) or A1 Sitemap Generator (commercial). If you just have a small website, and you just need standard XML sitemaps... Then any program/service will probably do :)
|
|