yomi-searchでgoogleサイトマップ作成
yomi-searchで、カテゴリを作成したときに、googleサイトマップを作成するように改造してみました。
ここでは、サイトは、http://A.com/で、yomi-searchディレクトリにyomi-searchのファイルを展開しているとしています。topページは、http://A.com/index.htmlで、作成するサイトマップは、http://A.com/sitemap.xmlです。topページだけプライオリティを1.0に上げています。
templateディレクトリ(kt.htmlなどがあるところ)にsitemap.xmlとファイルを以下の内容で作成します。
後半にgoogleサイトマップsitemap.xmlを上のテンプレートで作成する部分を追加します。
ここでは、サイトは、http://A.com/で、yomi-searchディレクトリにyomi-searchのファイルを展開しているとしています。topページは、http://A.com/index.htmlで、作成するサイトマップは、http://A.com/sitemap.xmlです。topページだけプライオリティを1.0に上げています。
templateディレクトリ(kt.htmlなどがあるところ)にsitemap.xmlとファイルを以下の内容で作成します。
print<<"<!--XML-->";
<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc>http://A.com/index.html</loc>
<priority>1.0</priority>
</url>
<!--XML-->
print "<url><loc>http://A.com/yomi-search/html/sitemap.html</loc></url>";
&gane_guide;
foreach(sort keys %ganes){
print "<url><loc>$Ekt$_$Eend</loc></url>";
}
print<<"<!--XML-->";
</urlset>
<!--XML-->
1;
admin.cgiのsitemap.htmlを作成するサブルーチン「sub sitemap_make{」を見つけます。後半にgoogleサイトマップsitemap.xmlを上のテンプレートで作成する部分を追加します。
sub sitemap_make{
#(cfg6)サイトマップを作成(&sitemap_make)
open(OUT,">$EST{html_path}sitemap.html");
select(OUT);
require "$EST{temp_path}sitemap.html";
select(stdout);
close(OUT);
#Google Sitemaps
open(OUT,">../sitemap.xml");
select(OUT);
require "$EST{temp_path}sitemap.xml";
select(stdout);
close(OUT);
}
カテゴリ変更とログファイルの更新を一緒に行う場合には、更新時間を設定することも可能だと思います。
その場合のsitemap.xmlテンプレートは、
その場合のsitemap.xmlテンプレートは、
print<<"<!--XML-->";
<?xml version="1.0" encoding="UTF-8" ?>
<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
<url>
<loc>http://A.com/index.html</loc>
<priority>1.0</priority>
</url>
<!--XML-->
my @gtime=gmtime(time);
print "<url><loc>http://A.com/yomi-search/html/sitemap.html</loc><lastmod>";
printf("%04d-%02d-%02dT%02d:%02d:%02d+00:00",$gtime[5]+1900
,$gtime[4]+1,$gtime[3],$gtime[2],$gtime[1],$gtime[0]);
print "</lastmod></url>";
&gane_guide;
foreach(sort keys %ganes){
print "<url><loc>$Ekt$_$Eend</loc><lastmod>";
printf("%04d-%02d-%02dT%02d:%02d:%02d+00:00",$gtime[5]+1900
,$gtime[4]+1,$gtime[3],$gtime[2],$gtime[1],$gtime[0]);
print "</lastmod></url>";
}
print<<"<!--XML-->";
</urlset>
<!--XML-->
1;
カテゴリー:ホームページの小技
