On a Drupal 8.9.13 website, I've removed the permission "View published content" from the Anonymous user. By default, when someone visits the front page, Drupal will then display:
Access denied
You are not authorized to access this page.
I want to replace this with some other text, e.g.
Please create an account to see our content.
To do this I try to create something like this in page--front.html.twig
.
{% if not logged_in %}
<p>Please create an account to see our content.</p>
{% endif %}
However, I am stuck 😞.
- I am not able to get rid of the "Access denied" text for the anonymous user.
- I can't get the the text "Please create an account to see our content." to show for the Anonymous user. (If I remove "not" from the if-test it shows up as expected on the front page for the Authenticated user).
The site's theme is an otherwise unmodified subtheme of Bootstrap Barrio 5.1.4, but I don't think the problem is theme-dependent. Rather, the problem is that I don't understand the interplay between Twig and permissions (IMHO, there should be none).