How to Create Hierarchical Content in Drupal 9

Drupal makes it possible for you to make hierarchical content without needing to install third-party modules. This possibility is already included in Drupal 9 :)

This kind of content is useful when you want to place similar and related content for your website. For instance, tutorials, goods etc.

As mentioned, this feature is pre-build in Drupal 9, but it has not been activated and installed. To create hierarchical content, you must Install one of the included modules in Drupal called Book module. You do not need to download this module, you just need to install it.

Follow these steps to install Book module and make hierarchical content for your Drupal 9 site.

Go to the admin panel of your Drupal site, and click on the Manage -> Extend and from the list of modules, search for Book, then mark the checkbox next to it and click on the Install button.

Click on the Install button
Click on the Install button

After the installation completes, this module is ready to use. Now you can go to the Structure -> Content types. You can see an added section to it which is called Book page. Click on the Manage fields.

Add a link field, type a title for it.

Click on the Add field Button
Click on the Add field Button

Here we choose Related Articles for the title and then click on the Save and continue button.

Now set the allowed number of values to unlimited and click on the Save field settings.

Set to Unlimited and Save it
Set to Unlimited and Save it

Now you need to make your Books contents. Click on the Structure -> Books.

You can change the Settings of the Books section if needed, but usually you don’t need to change them. The default settings are as this image. If you have made any changes, click on the Save configuration button.

Save the Settings
Save the Settings

Now you have done setting up the necessities, now you can make the contents for this very Books content type. To make content, click on the Content -> Add content -> Book page.

Choose the title, type the body part and click on the Book Outline on the right column. You can add other fields like images, tags etc. to the content.

Write the Content and Save it
Write the Content and Save it

After creating this content, you will see that there is an extra field called Outline

You can click on it and change the weight of it to any number you would like according to your requirements. The lower the value is, the higher it will look at the hierarchical items. But you can also change it visually; we will explain that later.

Change the Weight and Save to create Hierarchical Content
Change the Weight and Save

Now let’s add some more Book type content to see how the hierarchy works.

After adding more content, click on the Structure -> Books -> Edit order and titles.

You can change the position of items vertically to show them higher or lower and place one or more items as subcategory of a higher item etc. like the following image.

Changing Hierarchical Content
Changing Hierarchical Content

You might also like
Leave a comment

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More