Differences

This shows you the differences between two versions of the page.

Link to this comparison view

tech:others:dokuwiki_sitemap [2014/11/15 09:13] (current)
Line 1: Line 1:
 +====== Dokuwiki sitemap ======
 +Dokuwiki has a sitemap button which is convenient, but not search engine friendly. ​ It also has an [[https://​www.dokuwiki.org/​sitemap|Sitemap plugin]] that creates an XML sitemap for submission to search engines manually. ​ However to automate and make it automatically search engine friendly I created a quick sitemap script. ​ This script also categories by namespace (only one level). ​ Below is the script and I have it as a cron job so I have a nearly current list at all times.
 +
 +<code php>
 +#​!/​usr/​bin/​php
 +<?php
 +//
 +// Call from shell by passing output of find command to wiki path
 +// Example: If wikipath is /​www/​example.org/​somefolder/​wiki/​data/​pages
 +// MAINWIKIPATH=/​www/​example.org/​somefolder/​wiki/​data/​pages
 +// Usage: find $MAINWIKIPATH | cut -d"/"​ -f8-99 | sort | $MAINWIKIPATH/​sitemap.php > $MAINWIKIPATH/​sitemap.txt
 +// The sort is important so it can group and title the pages correctly
 +//
 +$f = fopen( '​php://​stdin',​ '​r'​ );
 +$replaceo = 1;
 +
 +while( $line = fgets( $f ) )
 +{
 +    $nocrline = str_replace("​\n",​ "",​ $line);
 +    //$fline = preg_replace("/​^tech\//",​ "",​ $nocrline, $replaceo);
 +    $fline = $nocrline;
 +    $pos = strpos($line,​ '​.txt'​);​
 +    if ($pos === false)
 +    {
 +        echo "​====== ", ucfirst($fline),​ " ======"​ , "​\n";​
 +    }
 +    else
 +    {
 +        $lline = preg_replace("/​.txt$/",​ "",​ $nocrline, $replaceo);
 +        // This line to replace / with : may not be required if wiki is configured to use clean URLs
 +        $lline = preg_replace("/​\//",​ ":",​ $lline);
 +        echo " ​ * [[", $lline, "​]]",​ "​\n";​
 +    }
 +}
 +
 +fclose( $f );
 +?>
 +</​code>​
  

QR Code
QR Code tech:others:dokuwiki_sitemap (generated for current page)