1

I know how to add content in Grav CMS but i am facing problem in how to add a header section in Grav CMS. Please tell me where do i have to write the code for header and footer. In (.md) files or twig files?

  • There is no single way as for how to do this in Grav, as Grav does not impose such rules on you. You can do it any way you like. Personally, I usually have `partials/header.html.twig` and `partials/footer.html.twig` around, which I then include in my base template, `{% include 'partials/footer.html.twig' %}`, etc – domsson Apr 12 '20 at 11:31

1 Answers1

1

As domsson already noted, there are more than a single way to do it in Grav

  1. You can check implementation of it in (default) Quark theme: templates/partials/base.html.twig, which is used by all other templates, have in needed location {% include 'partials/footer.html.twig' %} and footer.html.twig, in turn, contain all needed data for rendering on page

  2. You can also see (use) idea from Open Publishing Space skeleton

{# display footer markdown page - hibbittsdesign.org #} {% set content = pages.find('/footer').content %} {% if content %} {{ content|raw }} {% endif %}

Here ordinary page (/footer) from site (editable as much as needed) used instead of template and have anything in it, it's content used as site-footer

  1. If you have site with modular-pages only (like, f.e. Deliver skeleton), you can also (except using base-template as per p.1) add to all modular-collections

content: items: @self.modular …

page, which share common template (and data)

Lazy Badger
  • 94,711
  • 9
  • 78
  • 110