Adding sitemap to robots.txt.

This commit is contained in:
sergiotarxz 2023-05-03 01:02:51 +02:00
parent aa00c1a699
commit 8692a4d9fa
3 changed files with 15 additions and 3 deletions

View File

@ -29,6 +29,7 @@ sub startup ($self) {
# Normal route to controller
$r->get('/')->to('Page#index');
$r->get('/sitemap.xml')->to('Sitemap#sitemap');
$r->get('/robots.txt')->to('Robots#robots');
# $r->get('/:post')->to('Page#post');
$r->get('/stats')->to('Metrics#stats');

View File

@ -0,0 +1,14 @@
package BurguillosInfo::Controller::Robots;
use Mojo::Base 'Mojolicious::Controller', '-signatures';
sub robots($self) {
my $robots_txt = <<"EOF";
Sitemap: @{[$self->config('base_url')]}/sitemap.xml
User-Agent: *
Disallow: /stats
Disallow: /stats/*
EOF
$self->render(text => $robots_txt, format => 'txt');
}
1;

View File

@ -1,3 +0,0 @@
User-Agent: *
Disallow: /stats
Disallow: /stats/*