Skip to content

Instantly share code, notes, and snippets.

@russmckendrick
Last active December 30, 2015 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save russmckendrick/7847695 to your computer and use it in GitHub Desktop.
Save russmckendrick/7847695 to your computer and use it in GitHub Desktop.
Ghost Site Map
#!/bin/bash
url="yourdomain.com"
path="/path/to/ghost/sitemap/sitemap.xml"
date=`date +'%FT%k:%M:%S+00:00'`
freq="daily"
prio="0.5"
rm -f $path
list=`wget -r --delete-after $url --reject=.rss.gif,.png,.jpg,.css,.js,.txt,.ico 2>&1 |grep "\-\-" |grep http | awk '{ print $3 }'`
array=($list)
echo ${#array[@]} "pages detected for $url"
echo '<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' >> $path;
for ((i=0;i<${#array[*]};i++)); do
echo "<url>
<loc>${array[$i]:0}</loc>
<priority>$prio</priority>
<lastmod>$date</lastmod>
<changefreq>$freq</changefreq>
</url>" >> $path
done
echo "</urlset>" >> $path
#notify google
wget -q --delete-after http://www.google.com/webmasters/tools/ping?sitemap=http://$url/sitemap.xml
rm -r ${url}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment