I want to have the HOME page of my drupal 8 website public and all the rest you need to be authenticated.
I manage to have all the pages accessible when you are authenticated but I do not know how to make the home page visible publicly and to avoid to have “access denied”.
Thanks for your tips …
Does the home page have the same content type as the rest of the pages? Do you want to restrict access in content type or node level?
I was thinking to restrict at the node level, if possible because the content type is BASIC PAGE and used elsewhere.
In general you can find different modules to grant permissions and access. However only a few of them can modify the node level and most of them are not stable, which can create long term issues.
The one I found that is stable is the Permissions By Term module and is stable, hence safe. What it does is that it grants access based on the Term that is tagged with.
The steps I suggest to follow are:
- Install and enable the module
Create a vocabulary to tag nodes and differentiate their access. For example you can name it “Access”.
- Also create at least 2 terms: Public (they are accessible for everyone) and Registered (accessible only for registered users). When you create the term, you can choose who has to view in the permissions options.
- Create a field in the content type that you want to limit accessibility. It should be of type Reference to taxonomy term. Make sure to make the field required and also to set the Registered term as default. The last one is very important because if you dont set default then more nodes will be accessible
- Visit the node you want to make public and tag it as public.
- Dont forget to test it to visit both the node and the edit form both from registered and non registered users.
Let me know if you have more questions.