How to Use the Drupal Book Module
With the Drupal Book module, it is possible to create collections of related pieces of documents presented in a hierarchy. This format is suitable for handbooks and tutorials, for example.
Notice: This module is not for creating ebooks.
The Book module comes by default (disabled) with Drupal core modules, so there is no need to download or install anything additional on your system.
Keep reading to learn how to use this module!
Step #1. – Enable the Module
- Click Extend.
- Scroll down and enable the Book module.
- Click Install.
Step #2. – The Book Content Type
- Click Structure > Content types.
There is a new content type in addition to the 2 Drupal default content types called the Book page Content type.
- Click Manage fields.
Add an image field with the default settings.
- Add a link field.
- Give it proper title.
- Click Save and continue.
- Set the allowed number of values to unlimited.
- Click Save field settings.
- Click Manage display.
- Hide the image label.
- Rearrange the fields.
- Click Save.
Step #3. – The Book Outline
- Click Structure > Books.
You will be presented with a list of book outlines. At the moment this list is empty, since we haven’t created any book yet.
- Click the Settings tab.
You have two settings here:
- the content types allowed in book outlines (you can select multiple options here)
- the default content type (one value allowed) added when you click the “Add page” link
- Leave default values
- Click Save configuration.
Step #4. – Create a Book
- Click Content > Add content > Book page
- Enter a proper title and body text.
- Add a proper image.
- Click Book Outline on the right column.
- Select Create a new book from the dropdown.
- Click Save.
When seeing the published node, you will notice an extra tab on the top called Outline.
You can click here at any time and rearrange the outline of this particular node within the book hierarchy. This is also possible through the Books outline interface we saw on the step before.
Since we have created only the main page of our book, you will not be able to configure anything here.
- Click Update Book outline.
- Scroll down to the bottom of the book page.
- Click Add child page
This will take you directly to the Book page edit screen.
- Add proper content
- Click Save.
- Change the weight to -15 (if you will have more than 16 child pages, you will have a problem to place the last one at the end) as a security measure.
As a matter of fact, this is more a quirk, since you can rearrange book pages through a drag and drop interface within the book outline.
- Click Save.
Let’s add some more pages to “modelate” the structure detailed on the image. Use the column on the right of each node you edit.
When you have finished, take a look at the published nodes.
Nodes with child pages, will display a list of links containing them. Furthermore you have on the bottom, three additional links. Two of them point to the previous and next articles according to the sequence on the hierarchy.
The link labeled “Up” takes you to the corresponding parent page, that is, one level up.
To check the finished outline,
- Click Structure > Books > Edit order and titles.
You can rearrange the structure and order of your book here.
- Click Save book pages after you are finished editing.
The book navigation links can be styled through the css class .book-navigation or through its particular id.
I hope you liked this tutorial. Thanks for reading!
Good overview. Some folks might be interested that we added a new Book Navigation component to Layout Builder Kit since the built-in one is formatted in a restricted way:
https://www.drupal.org/project/layout_builder_kit
Great tutorial! If you find the Book module useful but wish the menu for it was more flexible, please check out the [url=https://www.drupal.org/project/custom_book_block]Custom Book Block[/url] module I made. Patches and feature requests are welcome!
Is it possible to have a node exist in two (or more) separate books? Would be very useful.
Sorry to say Robb, but the answer is no. Each node belongs to one section of a specific book only.
Thanks Jorge ! it’s a great tutorial and very clear !!
It will be wonderful if one day you could do an other one to explain how to display in Drupal 8 the total tree on a page (for navigation), and how to style in different way the tree (the complet one and the childs’one), may be a tutorial with layout builder kit ?… Have a nice day 🙂
Helpful content.
Is there any way to add more number of FAQs to a drupal website without manually typing it or by copy-pasting??
Is there a way to add a search feature that only searches the book?