Bug 33317: Add system preference to set meta robots for the OPAC

Websites must have a robots meta tag to improve search engine crawling,
so we could tell search engines to not index OPAC pages for example.

To test:

1) Look at opac-main source and see that meta name=robots is missing.
2) Apply patch.
3) Run ./installer/data/mysql/updatedatabase.pl
4) Go to system preferences > OPAC and add some directives to
   OpacMetaRobots (ex: noindex,nofollow).
5) Look at opac-main source and confirm that meta name=robots now has
   content equal to the text set in the OpacMetaRobots system
   preference.
6) This should Prevent search engines from indexing Opac pages (if
   OpacMetaRobots is set to noindex)

Signed-off-by: Owen Leonard <oleonard@myacpl.org>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Hammat Wele 2023-04-28 22:21:12 +00:00 committed by Katrin Fischer
parent c3166f6efe
commit f4abf0393a
Signed by: kfischer
GPG key ID: 0EF6E2C03357A834
4 changed files with 22 additions and 0 deletions

View file

@ -0,0 +1,14 @@
use Modern::Perl;
return {
bug_number => "33317",
description => "Add new system preference OpacMetaRobots",
up => sub {
my ($args) = @_;
my ($dbh, $out) = @$args{qw(dbh out)};
$dbh->do(q{INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('OpacMetaRobots','','','Improve search engine crawling.', 'Textarea') });
say $out "Added system preference 'OpacMetaRobots'";
},
};

View file

@ -509,6 +509,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('OPACMandatoryHoldDates', '', '|start|end|both', 'Define which hold dates are required on OPAC reserve form', 'Choice'),
('OpacMaxItemsToDisplay','50','','Max items to display at the OPAC on a biblio detail','Integer'),
('OpacMetaDescription','','','This description will show in search engine results (160 characters).','Textarea'),
('OpacMetaRobots','','','Improve search engine crawling.','Textarea'),
('OPACMySummaryHTML','','70|10','Enter the HTML that will appear in a column on the \'my summary\' and \'my checkout history\' tabs when a user is logged in to the OPAC. Enter {BIBLIONUMBER}, {TITLE}, {AUTHOR}, or {ISBN} in place of their respective variables in the HTML. Leave blank to disable.','Textarea'),
('OpacNewsLibrarySelect','0','','Show selector for branches on OPAC news page','YesNo'),
('OpacNoItemTypeImages','0',NULL,'If ON, disables itemtype images in the OPAC','YesNo'),

View file

@ -60,6 +60,10 @@ OPAC:
- "This description will show in search engine results (160 characters)."
- pref: OpacMetaDescription
type: textarea
-
- "Improve search engine crawling."
- pref: OpacMetaRobots
type: textarea
-
- By default, show bibliographic records
- pref: BiblioDefaultView

View file

@ -11,6 +11,9 @@
[% IF ( Koha.Preference('OpacMetaDescription') ) %]
<meta name="description" content="[% Koha.Preference('OpacMetaDescription') | html %]" />
[% END %]
[% IF ( Koha.Preference('OpacMetaRobots') ) %]
<meta name="robots" content="[% Koha.Preference('OpacMetaRobots') | html %]" />
[% END %]
<link rel="shortcut icon" href="[% IF ( Koha.Preference('OpacFavicon') ) %][% Koha.Preference('OpacFavicon') | url %][% ELSE %][% interface | url %]/[% theme | url %]/images/favicon.ico[% END %]" type="image/x-icon" />
<link rel="apple-touch-icon" href="[% IF ( Koha.Preference('OpacFavicon') ) %][% Koha.Preference('OpacFavicon') | url %][% ELSE %][% interface | url %]/[% theme | url %]/images/favicon.ico[% END %]" type="image/x-icon" />
[% IF ( Koha.Preference('opaclayoutstylesheet') && Koha.Preference('opaclayoutstylesheet') != "opac.css" ) %]