Announcement communicates page-related messages. For example, to acknowledge that certain page is getting outdated, or it is being worked on; therefore, to provide transient awareness during the page edition process.
Announcement can be dismissed pressing the close button visible on its right side.
Announcement is less relevant than breakingnews.
Presentation template
Announcement presentation template is defined in the _includes/base/announcements.html
file.
Announcement presentation template arranges a bullhorn icon () on the left side and a regular content on the right side.
Configuration files
Announcement presentation template reads configuration variables from configuration files described below:
-
Site’s configuration file:
_config.yml
Set default values for both site and page-specific configuration variables.
-
Page preamble section of markdown files:
**/*.md
Set custom values for page-specific configuration variables. Page configuration variables defined in page preamble section of markdown files override page configuration variables defined in site’s configuration file.
Configuration variables
Announcement configuration variables are described in the following table:
Name | Description |
---|---|
with_announcements |
The announcement switcher. Possible values are true or false (default). When the value is true , you need to provide the with_announcements_data variable with the announcements information you want to present. |
with_announcements_data |
The announcement configuration. This variable accepts a list of announcements you want to present. When more than one announcement is provided, they are presented in the same order they were entered in the list. |
The with_announcements_data
list items accept the properties described in the table below:
Name | Description |
---|---|
content |
Announcement content. |
color |
Announcement color. Possible options include primary (default), secondary , info , warning , danger , success , dark , light . |
icon |
The announcement icon class rendered on the left side. Possible options to use use here are limited to fontawesome freely distributed icons. When no icon class is provided, fa-solid fa-bullhurn is used by default. |
Showing announcement at page level
---
title: This is a page with announcement
with_announcements: true
with_announcements_data:
- content: My announcement content.
---
Some content here.
To show announcement at page level, do the following:
-
Add
with_announcements
configuration variable to page preamble in Markdown files with valuetrue
. -
Add
with_announcements_data
configuration variable to page preamble in Markdown files withcontent
, and others supported property, set to the message you want to communicate.
Showing announcement at page content level
---
title: This is a page with announcements at page content level
with_section_announcements_1:
- content: This section is under construction!
with_section_announcements_2:
- content: This section is outdated!
---
## Section 1
{% include base/announcements.html
announcements = page.with_section_announcements_1
%}
Some content here.
## Section 2
{% include base/announcements.html
announcements = page.with_section_announcements_2
%}
Some content here.
To show announcement message at page content level, do the following:
-
Add a custom
with_<name>_announcements_data
page configuration variables in the page preamble of Markdown files. These variables should have the same propertieswith_announcements_data
configuration variable has.with_section_announcements_1: - content: This section is under construction!
-
Include announcement presentation template passing a custom page configuration variable as argument.
{% include base/announcements.html announcements = page.with_section_announcements_1 %}
Showing announcement at site level
To show announcement at site level, set configuration variables in the site configuration file _config.yml
, as described in the configuration example below.
# site.defaults - Set global default values.
defaults:
- scope:
path: "" # an empty string here means all files in the project.
values:
with_announcements: true
with_announcements_data:
- content: My announcement content.
Hiding announcement at page level
---
title: This is a page with announcement
with_announcements: false
---
Some content here.
To hide announcement at page level, set with_announcements
configuration variable to false
in the page preamble of Markdown files.
Hiding announcement at site level
# site.defaults - Set global default values.
defaults:
- scope:
path: "" # an empty string here means all files in the project.
values:
with_announcements: false
To hide announcement at site level, set with_announcements
configuration variable to false
in the site configuration file _config.yml
, as described in the configuration, under defaults values.