Macro newbie question

I have a huge site with more than 1500 pages.
On each of them I wold like add a ‘see also’ section which lists all related pages, like

## See also
{% for post in taxonomy.findTaxonomy({'category':'docs'}) %}
    <li><a href="{{ post.url }}">{{ post.title }}</a></li>
{% endfor %}

A macro is probably the best choice something like:

{% macro see_also(category) %}

I have 2 precises questions:

  1. in which file should I create this macro and in which folder?
  2. how to call the macro inside the pages (sorry for this newbie question, but it’s not so clear for me in the doc)

thanks for your help

First of all, consider using the Related Pages plugin already available.

If that doesn’t do what you want, then here’s the general outline of what to do:

  1. Follow these instructions and inherit the theme you’re currently using. This way you can update the base theme without losing your customizations.

  2. Create a new partial called something like user/themes/mytheme/templates/partials/relatedpages.html.twig that encapsulates the logic and formatting of the “see also” section you’re trying to build.

  3. {% include %} that new partial into whatever page template you want it to appear: Twig docs.

thanks a lot for your answer+++++