While comments are connected to the article content type by default in Drupal 8, there are others that do not. In these cases, such as the page content type, it will need to be added to the default structure. Follow along below as we guide you on how to add the comment field to a basic page in Drupal 8.
How to enable comments for a basic page
- Log into your Drupal 8 admin interface.
Using the top menu bar, select the Menu option. From there, another menu will appear below. Choose the Structure option from the second menu.
This will bring up a screen of all the structure types. Click on the Content types to continue.
This will list all of the current content types available. The procedure for adding a comment field is the same regardless of content type. Select the content type you want to work with. We will work with the Basic page content type. Click on the Manage fields option from the dropdown to the right side of the Basic page row.
This leads you to the Basic page settings page. You will see the basic fields for the basic page, which is the body field. Under this field is an empty field labeled Add new field> Give the comment field a name here, most likely something line ‘comment‘.
- Next, move to the dropdown to the right and select the field type Comments from the list.
- Once you have completed that, click on the Save button at the bottom of the page. This will activate your new comment field for the basic page (or whichever content type you worked with).
Default Coment field added
Thoughts on “Adding a comment field to a basic page in Drupal 8”
I am essentially satisfied with your great work. The attached patch refactors the module to allow it to take into account the id attribute of the wrapper element for a given comment field.