首页  编辑  

InnoKB如何生成Sitemap文件以便搜索引擎可以检索内容?

Tags: /计算机文档/软件应用技巧/   Date Created:
InnoKB如何生成Sitemap文件以便搜索引擎可以检索内容?
How to create sitemap.xml for InnoKB for search engine(such as Google, Bing, Baidu)?
1. 创建一个sitemap.sh Linxu脚本,内容如下,其中把对应的目录和数据库ID名字更改即可。
XML='/<your folder>/innokb/repository/<your dbid>/__db_info.xml'
FILE='/<your folder>/innokb/html/sitemap.xml'
IDS='/tmp/ids.txt'
sed -n 's/.*ii id="\([^ ]*\)".*tm0="\(.*\)".*/\1/p' $XML > $IDS echo '<?xml version="1.0" encoding="UTF-8"?>' > $FILE echo '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' >> $FILE cat $IDS | while read line do
  echo "<url><loc>http://<your_site_url>/archive/SuperKB/"$line"/</loc></url>" >> $FILE done
echo '</urlset>' >> $FILE
然后加入crontab,每隔一段时间运行一次即可。
crontab -e,添加类似一行代码,其中记得更改<your path>为你的sitemap.sh所在的目录,改指令每天晚上0:0即更新一次sitemap文件:
0 0 * * * /<your path>/sitemap.sh