How to include book traversal links on a custom twig template page I use the Book module to create books with chapters.
When I use the default twig template node.html.twig to display a book chapter, a section titled "Book traversal links" is included, with links to the previous chapter, the next chapter, and to the book. The debugger says these links come from the book-navigation.html.twig template.
Instead of the default template, I'm using a custom twig template node--chapter.html.twig to display chapters.


QUESTION:

How can I get the same book traversal links onto my custom page?

NOTES:


I checked for a block containing the book traversal links that I could just insert in my twig template, but I don't see one.
I have checked the $variables array in the twig template to see if maybe a list of the chapter's siblings is already there, but don't see one.
I'm already using HOOK_preprocess_node(&amp;$variables) to find the book parent book's id, so I can use it to find the chapter's siblings, if that's the way to go.
Alas, there is no block for this; the book navigation links are hacked on to the node view in core.

From core/modules/book/book.module:

/**
 * Implements hook_ENTITY_TYPE_view() for node entities.
 */
function book_node_view(array &amp;$build, EntityInterface $node, EntityViewDisplayInterface $display, $view_mode) {
  if ($view_mode == 'full') {
    if (!empty($node-&gt;book['bid']) &amp;&amp; empty($node-&gt;in_preview)) {
      $book_node = Node::load($node-&gt;book['bid']);
      if (!$book_node-&gt;access()) {
        return;
      }
      $build['book_navigation'] = [
        '#theme' =&gt; 'book_navigation',
        '#book_link' =&gt; $node-&gt;book,
        '#weight' =&gt; 100,
        // The book navigation is a listing of Node entities, so associate its
        // list cache tag for correct invalidation.
        '#cache' =&gt; [
          'tags' =&gt; $node-&gt;getEntityType()-&gt;getListCacheTags(),
        ],
      ];
    }
  }
}


The good news is that this should work with custom templates as long as you are using the full view mode.

I have a custom node template and I still get the navigation links on my books at the bottom of the content.  (Unfortunately, whether I want them there or not-- as per the above code, they are forcibly added and there is no UI to control them.)