<header>
    <div>
        <div class="grav-c-page-header__logo">
            <a href="#">
                <svg role="img" class="grav-c-logotype" aria-labelledby="logo-buildit-logotype__title" width="300" height="33">
                    <use xlink:href="#logo-buildit-logotype"></use>
                </svg></a>
        </div>
        <button class="grav-c-toggle-menu" type="button" aria-pressed="false" aria-label="Toggle navigation menu">
            <span class="grav-c-toggle-menu__icon"></span>
        </button>
        <nav class="grav-c-nav-menu">
            <ul>

                <li>
                    <a class="grav-c-nav-link" href="#">Lorem ipsum</a>
                </li>

                <li>
                    <a class="grav-c-nav-link" href="#">Quis autem</a>
                </li>

                <li>
                    <a class="grav-c-nav-link" href="#">Sed ut perspiciatis unde omnis</a>
                </li>

                <li>
                    <a class="grav-c-nav-link">Neque porro</a>
                </li>

                <li>
                    <a class="grav-c-nav-link" href="#">Nemo</a>
                </li>

                <li>
                    <a class="grav-c-nav-link" href="#">Unquam sit</a>
                </li>

                <li>
                    <a class="grav-c-nav-link" href="#">Mors tua vita mea</a>
                </li>

                <li class="grav-c-nav-menu__external-link">
                    <a class="grav-c-nav-link" href="#">Praesent eu</a>
                </li>

                <li class="grav-c-nav-menu__external-link">
                    <a class="grav-c-nav-link" href="#">Donec sagittis</a>
                </li>
            </ul>
        </nav>
    </div>
</header>
{%- from '@nav-menu' import navMenu -%}

{%- from '@link' import link -%}
{%- from '@toggle-menu' import toggleMenu -%}

{# Reusable macro for other templates to import: #}
{%- macro pageHeader(links, externalLinks, logoLink = false, navMenuExpanded = false, withClass = false) -%}
  {%- set logoType -%}
    {% include '@logotype' %}
  {%- endset -%}

  <header{% if withClass %} class="grav-c-page-header"{% endif %}>
    <div>
      <div class="grav-c-page-header__logo">
        {% if logoLink -%}
          {{ link(logoType, logoLink) | safe }}
        {%- else -%}
          <h1>
            {% include '@logotype' %}
          </h1>
        {%- endif %}
      </div>
      {{ toggleMenu(navMenuExpanded) }}
      {{ navMenu(links, externalLinks) | safe }}
    </div>
  </header>
{%- endmacro -%}

{# Example rendering: #}
{%- block example -%}
  {{ pageHeader(header.links, header.externalLinks, header.url, withClass = header.withClass) | safe }}
{%- endblock -%}
{
  "text": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam",
  "url": "#",
  "listItems": [
    {
      "htmlContent": "Some list item content"
    },
    {
      "htmlContent": "More list item content"
    },
    {
      "htmlContent": "Even more list item content"
    },
    {
      "htmlContent": "I can't believe there's still more list item content"
    },
    {
      "htmlContent": "Seriously?! That's enough now."
    }
  ],
  "footer": {
    "copy": "&copy; 2019 <strong>Buildit</strong>. All rights reserved.",
    "linksA": [
      {
        "label": "Stories",
        "url": "#"
      },
      {
        "label": "People",
        "url": "#"
      },
      {
        "label": "Jobs",
        "url": "#"
      }
    ],
    "linksB": [
      {
        "label": "Terms",
        "url": "#"
      },
      {
        "label": "Accessibility",
        "url": "#"
      },
      {
        "label": "Privacy & Cookie Policy",
        "url": "https://wiprodigital.com/privacy-policy"
      }
    ]
  },
  "hero": {
    "pullout": "Big, attention-grabbing headline",
    "paragraph": "Witty subtitle",
    "cta": {
      "text": "Clickbaity label",
      "url": "#"
    }
  },
  "img": {
    "random": {
      "src": "/images/img-random-1.png",
      "alt": "A placeholder image with an arbitrary aspect ratio."
    },
    "square": {
      "src": "/images/img-1x1.png",
      "alt": "A placeholder image with a perfect square (1:1) aspect ratio."
    },
    "tv": {
      "src": "/images/img-4x3.png",
      "alt": "A placeholder image with a 4:3 aspect ratio, like an old TV."
    },
    "widescreen": {
      "src": "/images/img-16x9.png",
      "alt": "A placeholder image with a 16:9 aspect ratio, like a widescreen TV."
    },
    "logo": {
      "src": "/images/img-random-2.png",
      "alt": "A test image for a logo with an arbitrary aspect ratio."
    }
  },
  "title": "Page title",
  "header": {
    "url": "#",
    "links": [
      {
        "text": "Lorem ipsum",
        "url": "#"
      },
      {
        "text": "Quis autem",
        "url": "#"
      },
      {
        "text": "Sed ut perspiciatis unde omnis",
        "url": "#"
      },
      {
        "text": "Neque porro",
        "url": false
      },
      {
        "text": "Nemo",
        "url": "#"
      },
      {
        "text": "Unquam sit",
        "url": "#"
      },
      {
        "text": "Mors tua vita mea",
        "url": "#"
      }
    ],
    "externalLinks": [
      {
        "text": "Praesent eu",
        "url": "#"
      },
      {
        "text": "Donec sagittis",
        "url": "#"
      }
    ]
  },
  "sections": [
    {
      "title": "Example section",
      "class": "grav-o-full-bleed__content",
      "content": [
        {
          "paragraph": "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam."
        }
      ]
    }
  ],
  "section": {
    "title": "This is the title for a section",
    "class": "grav-o-full-bleed__content",
    "content": [
      {
        "paragraph": "Paragraph lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua."
      },
      {
        "blockquote": "Blockquote lorem ipsum dolor sit amet, consectetur adipisicing elit"
      },
      {
        "twoColumnsList": [
          {
            "htmlContent": "Vestibulum auctor dapibus neque."
          },
          {
            "htmlContent": "Lorem ipsum dolor sit amet, consectetuer adipiscing elit."
          },
          {
            "htmlContent": "Aliquam tincidunt mauris eu risus."
          },
          {
            "htmlContent": "Labore et dolore magna aliqua."
          },
          {
            "htmlContent": "Phasellus tempus, orci non mattis sagittis."
          }
        ]
      },
      {
        "inlineRow": [
          {
            "text": "First link",
            "url": "#"
          },
          {
            "text": "Second link",
            "url": "#"
          },
          {
            "text": "Third link",
            "url": "#"
          }
        ]
      },
      {
        "imgCards": [
          {
            "title": "Some fascinating, attention-grabbing headling",
            "content": "Ideally, with a click-baity tagline that entices to you to visit!",
            "image": {
              "src": "/images/img-random-1.png",
              "alt": "Brief description of this fascinating image"
            }
          },
          {
            "title": "Labore et dolore magna aliqua",
            "content": "Vestibulum pharetra arcu enim, nec porttitor quam ullamcorper et. Phasellus tempus, orci non mattis sagittis, lectus erat fringilla odio, nec auctor erat augue quis eros.",
            "image": {
              "src": "/images/img-random-1.png",
              "alt": "Phasellus tempus, orci non mattis"
            }
          },
          {
            "title": "Nanotechnology immersion along the information highway",
            "content": "Leverage agile frameworks to provide a robust synopsis for high level overviews.",
            "image": {
              "src": "/images/img-random-1.png",
              "alt": "Bring to the table win-win survival strategies"
            }
          }
        ]
      },
      {
        "imgLinks": [
          {
            "url": "#",
            "image": {
              "src": "/images/img-random-1.png",
              "alt": "Image linke #1"
            }
          },
          {
            "url": "#",
            "image": {
              "src": "/images/img-random-2.png",
              "alt": "Image linke #2"
            }
          },
          {
            "url": "#",
            "image": {
              "src": "/images/img-random-3.png",
              "alt": "Image linke #3"
            }
          }
        ]
      }
    ]
  }
}

Purpose

This is the main Page Header that sits above every page. It contains the company logo and main site navigation.

Ideally, the Page Header is a <header> element that is a direct child of <body>, in which case no class is necessary. For compatibility with frameworks or CMSes where you cannot add the page header as a direct child of <body>, you may use <header class="grav-c-page-header"> instead.

When using this component, make sure the following advice is followed:

  • The Page Header must be a descendent of <body> that is not nested with another sectioning element. This is so that it had an implict ARIA landmark role of banner.
  • There must only be 1 instance of a Page Header on a page

Home variant

This is a variation of the main Page Header component, where the Buildit logo is marked up as the level 1 heading of the page, rather than being a link. This intended for the use exclusively on the homepage of a website, because:

  • It is redundant for a page to link to itself (on other pages, the logo typically links to the homepage)
  • The “buildit @ wipro digital” title text of the logo SVG is a suitable H1 heading text for the homepage

See also