Skip to content

Commit 7bdf398

Browse files
committed
[userguide] Adds a page about banners
1 parent 76e4f32 commit 7bdf398

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

  • userguide/content/en/docs/adding-content
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
title: "Banners"
3+
date: 2024-02-22
4+
weight: 12
5+
description: >
6+
Add a banner above the page content.
7+
---
8+
9+
You can add custom banners above the page content of documentation and blog pages.
10+
11+
To display the banner, you have to:
12+
13+
1. Create a file in your project called `layouts/partials/hooks/banner.html`
14+
1. Edit the file to add the content of the banner. You can use HTML code, or anything that [Hugo partial templates](https://gohugo.io/templates/partials/) support. For example:
15+
16+
```html
17+
<div class="pageinfo pageinfo-primary">
18+
<p>This is a simple banner that appears if you set <code>banner</code> to <code>yes</code> in the front matter of the page.</p>
19+
</div>
20+
```
21+
22+
1. Set the `banner` option to `yes` in the front matter of the page you want the banner on.
23+
24+
To apply the banner to multiple pages, you can also [cascade](https://gohugo.io/content-management/front-matter/#cascade) the `banner` value.
25+
26+
If you want to use multiple different banners in your docs, you can create multiple separate banner files called `layouts/partials/hooks/<custom-banner-filename>`, and set the `banner` option to `yes`, and the `banner_file` option to `<custom-banner-filename>` in the front matter to display the specified file as banner. Note that currently only one banner can be displayed on a page: if you have both `banner` and `banner_class` set, only `banner_class` takes effect.

0 commit comments

Comments
 (0)