21 @ oct
XML sitemap generated thanks to a simple shell script
XML sitemaps are used by the main search engines to better crawl the website. I've written a simple shellscript that create a sitemap from static contents. It only include html files, and is based on the filesystem. What’s good enought for this kind of stuff (yeah, no flash, no dynamic urls, and so on :p)
This script create a simple xml sitemap that can be submitted to search engines, as, for example, Google and its Webmaster tools.
1 #!/bin/sh
2 DIR=.
3 URLENCODE=/usr/local/bin/urlencode.sh
4
5 echo 'Content-Type: application/xml'
6 echo ''
7 echo '<?xml version="1.0" encoding="UTF-8"?>'
8 echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'
9 echo '<channel>'
10 echo "<title>Zecrazytux's webpages: free softwares, GNU/Linux, BSD... SUPINFO student and Linux trainer</title>"
11 echo "<description>Zecrazytux's personnal webpages: articles about free softwares, system administration on GNU/Linux, *BSD, opensolaris... SUPINFO Linux Lab Trainer and BSD projects manager </description>"
12 echo '<link>http://zecrazytux.net/</link>'
13 echo '<atom:link href="http://zecrazytux.net/rss.sh" rel="self" type="application/rss+xml" />'
14
15 for file in $(find $DIR -name \*.md)
16 do
17
18
19 file=$(echo $file | sed -n 's/\.\///p')
20 url=$(echo $file | sed 's/\.md/\.html/')
21 lastmod=$(stat -f %Sm -t "%a, %d %b %Y %H:%M:%S %z" $file)
22 title=$(grep 'h1' $url | sed 's|</.*>||;s|<.*>||' | sed 's/&/&/g')
23 description="$(grep -A5 'h1' $url | tail -4 | sed 's|</.*>||;s|<.*>||' | sed 's/&/&/g')..."
24 url=$(echo $url | $URLENCODE | sed 's/%2F/\//g')
25
26 echo '<item>'
27 echo '<title>'$title'</title>'
28 echo '<description>'$description'</description>'
29 echo '<link>http://zecrazytux.net/'$url'</link>'
30 echo '<guid>http://zecrazytux.net/'$url'</guid>'
31 echo '<pubDate>'$lastmod'</pubDate>'
32 echo '</item>'
33
34 done
35
36 echo '</channel>'
37 echo '</rss>'
38
2 DIR=.
3 URLENCODE=/usr/local/bin/urlencode.sh
4
5 echo 'Content-Type: application/xml'
6 echo ''
7 echo '<?xml version="1.0" encoding="UTF-8"?>'
8 echo '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">'
9 echo '<channel>'
10 echo "<title>Zecrazytux's webpages: free softwares, GNU/Linux, BSD... SUPINFO student and Linux trainer</title>"
11 echo "<description>Zecrazytux's personnal webpages: articles about free softwares, system administration on GNU/Linux, *BSD, opensolaris... SUPINFO Linux Lab Trainer and BSD projects manager </description>"
12 echo '<link>http://zecrazytux.net/</link>'
13 echo '<atom:link href="http://zecrazytux.net/rss.sh" rel="self" type="application/rss+xml" />'
14
15 for file in $(find $DIR -name \*.md)
16 do
17
18
19 file=$(echo $file | sed -n 's/\.\///p')
20 url=$(echo $file | sed 's/\.md/\.html/')
21 lastmod=$(stat -f %Sm -t "%a, %d %b %Y %H:%M:%S %z" $file)
22 title=$(grep 'h1' $url | sed 's|</.*>||;s|<.*>||' | sed 's/&/&/g')
23 description="$(grep -A5 'h1' $url | tail -4 | sed 's|</.*>||;s|<.*>||' | sed 's/&/&/g')..."
24 url=$(echo $url | $URLENCODE | sed 's/%2F/\//g')
25
26 echo '<item>'
27 echo '<title>'$title'</title>'
28 echo '<description>'$description'</description>'
29 echo '<link>http://zecrazytux.net/'$url'</link>'
30 echo '<guid>http://zecrazytux.net/'$url'</guid>'
31 echo '<pubDate>'$lastmod'</pubDate>'
32 echo '</item>'
33
34 done
35
36 echo '</channel>'
37 echo '</rss>'
38