From 8692a4d9fa862a2b5f10d1f399e820fb0041da4c Mon Sep 17 00:00:00 2001 From: sergiotarxz Date: Wed, 3 May 2023 01:02:51 +0200 Subject: [PATCH] Adding sitemap to robots.txt. --- lib/BurguillosInfo.pm | 1 + lib/BurguillosInfo/Controller/Robots.pm | 14 ++++++++++++++ public/robots.txt | 3 --- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 lib/BurguillosInfo/Controller/Robots.pm delete mode 100644 public/robots.txt diff --git a/lib/BurguillosInfo.pm b/lib/BurguillosInfo.pm index 708cd87..f9f4c06 100644 --- a/lib/BurguillosInfo.pm +++ b/lib/BurguillosInfo.pm @@ -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'); diff --git a/lib/BurguillosInfo/Controller/Robots.pm b/lib/BurguillosInfo/Controller/Robots.pm new file mode 100644 index 0000000..d572873 --- /dev/null +++ b/lib/BurguillosInfo/Controller/Robots.pm @@ -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; diff --git a/public/robots.txt b/public/robots.txt deleted file mode 100644 index c5ca693..0000000 --- a/public/robots.txt +++ /dev/null @@ -1,3 +0,0 @@ -User-Agent: * -Disallow: /stats -Disallow: /stats/*