Last active
December 30, 2015 15:19
-
-
Save russmckendrick/7847695 to your computer and use it in GitHub Desktop.
Ghost Site Map
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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