Postlet

Custom Plugin Example: Global Notice Banner

Fri May 08 2026 · Postlet Team

This example shows a minimal plugin that contributes one template variable to all pages.

1. Create a plugin file

Create plugins/notice-banner.js:

export default function noticeBanner() {
  return {
    name: "notice-banner",
    siteContext() {
      return {
        noticeBannerHtml:
          '<div class="rounded-md border border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-900">Postlet demo: replace this banner in production.</div>'
      };
    }
  };
}

2. Register it

Load it in your plugin list and return it before page rendering hooks run.

3. Render in template

In templates/page.njk, add:


This pattern is ideal for site-wide announcements, beta labels, or migration notices.

YOU CAN PLACE ANY CUSTOM HTML HERE THAT WILL GO BEFORE CLOSING BODY TAG ... THIS IS DRIVEN BY analytics.js plugin