Skip to content

Commit

Permalink
[#3045] Add option to enable/disable indexing by search engines
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Schilling committed Feb 14, 2025
1 parent 3215c56 commit cfb57b0
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/open_inwoner/configurations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ class SiteConfigurationAdmin(OrderedInlineModelAdminMixin, SingletonModelAdmin):
{
"fields": (
"name",
"enable_indexing",
"login_show",
"login_allow_registration",
"enable_eherkenning_for_eenmanszaak",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.16 on 2025-02-14 11:49

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
("configurations", "0075_siteconfiguration_enable_eherkenning_for_eenmanszaak"),
]

operations = [
migrations.AddField(
model_name="siteconfiguration",
name="enable_indexing",
field=models.BooleanField(
default=True,
help_text="When enabled, search engines can index the site",
verbose_name="Enable indexing by search engines",
),
),
]
5 changes: 5 additions & 0 deletions src/open_inwoner/configurations/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,11 @@ class SiteConfiguration(SingletonModel):
"Display contact form on the questions list page so that users can create new questions"
),
)
enable_indexing = models.BooleanField(
verbose_name=_("Enable indexing by search engines"),
default=True,
help_text=_("When enabled, search engines can index the site"),
)

class Meta:
verbose_name = _("Site Configuration")
Expand Down
5 changes: 3 additions & 2 deletions src/open_inwoner/templates/master.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
<html lang="nl" class="view utrecht-document openinwoner-theme {% block view_class %}view--{{ request.resolver_match.namespaces|join:'-' }}-{{ request.resolver_match.url_name }}{% endblock %}">
<head>
<meta charset="utf-8">
<meta name="robots" {% if enable_indexing %}content="all"{% else %}content="noindex"{% endif %}>
<meta name="format-detection" content="telephone=no">
<title>{% block title %}{% if page_title %}{{ page_title }} - {% endif %}{{ site_name }}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Expand Down Expand Up @@ -63,7 +64,7 @@
</head>

<body hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' class="utrecht-page">

{% if cookiebanner_enabled %}
{# render cookiebanner first #}
<div class="cookie-banner" id="cookie-banner" aria-labelledby="cookie-banner__title" aria-describedby="cookie-banner__text">
Expand All @@ -79,7 +80,7 @@
</div>
</div>
{% endif %}

{% include "components/Header/AccessibilitySkipLink.html" %}

{% if warning_banner_enabled %}
Expand Down
1 change: 1 addition & 0 deletions src/open_inwoner/utils/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def settings(request):

context = {
"site_name": config.name,
"enable_indexing": config.enable_indexing,
"theming": {
"primary": config.get_primary_color,
"secondary": config.get_secondary_color,
Expand Down

0 comments on commit cfb57b0

Please sign in to comment.