From 32a35230d973c954bb2c89b487056863e9a581c8 Mon Sep 17 00:00:00 2001 From: Gabor Szabo Date: Sat, 9 Nov 2013 21:30:54 +0200 Subject: [PATCH] add robots.txt and generate sitemap.xml --- .gitignore | 1 + bin/generate.pl | 18 ++++++++++++++++++ html/robots.txt | 1 + 3 files changed, 20 insertions(+) create mode 100644 html/robots.txt diff --git a/.gitignore b/.gitignore index edce679..ee4eb88 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ *.swp html/*.html +html/sitemap.xml diff --git a/bin/generate.pl b/bin/generate.pl index af5c871..9dcb0c0 100644 --- a/bin/generate.pl +++ b/bin/generate.pl @@ -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{\n}; +$sitemap .= qq{\n}; + + foreach my $p (@pages) { open my $fh, '<', "pages/$p"; my %params = ( content => '' ); @@ -35,4 +41,16 @@ } } $tt->process('page.tt', \%params, "html/$p") or die $tt->error; + $sitemap .= qq{ \n}; + $sitemap .= qq{ http://dwimperl.com/$p\n}; + $sitemap .= qq{ $now\n}; + $sitemap .= qq{ \n}; } + +$sitemap .= "\n"; + +if (open my $out, '>', 'html/sitemap.xml') { + print $out $sitemap; +} + + diff --git a/html/robots.txt b/html/robots.txt new file mode 100644 index 0000000..28be2bf --- /dev/null +++ b/html/robots.txt @@ -0,0 +1 @@ +Sitemap: http://dwimperl.com/sitemap.xml