Skip to content

Commit

Permalink
add robots.txt and generate sitemap.xml
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Nov 9, 2013
1 parent 1e42e38 commit 32a3523
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.swp
html/*.html
html/sitemap.xml
18 changes: 18 additions & 0 deletions bin/generate.pl
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,22 @@
use autodie;

use Template;
use DateTime;
my $tt = Template->new({
INCLUDE_PATH => 'tt',
START_TAG => '<%',
END_TAG => '%>',
EVAL_PERL => 0,
});
my $now = DateTime->now->ymd;

my @pages = map { substr $_, 6 } glob "pages/*.html";
#print "@pages";

my $sitemap = qq{<?xml version="1.0" encoding="UTF-8"?>\n};
$sitemap .= qq{<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n};


foreach my $p (@pages) {
open my $fh, '<', "pages/$p";
my %params = ( content => '' );
Expand All @@ -35,4 +41,16 @@
}
}
$tt->process('page.tt', \%params, "html/$p") or die $tt->error;
$sitemap .= qq{ <url>\n};
$sitemap .= qq{ <loc>http://dwimperl.com/$p</loc>\n};
$sitemap .= qq{ <lastmod>$now</lastmod>\n};
$sitemap .= qq{ </url>\n};
}

$sitemap .= "</urlset>\n";

if (open my $out, '>', 'html/sitemap.xml') {
print $out $sitemap;
}


1 change: 1 addition & 0 deletions html/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sitemap: http://dwimperl.com/sitemap.xml

0 comments on commit 32a3523

Please sign in to comment.