Deploy non-emergency global banner
A site-wide (global) banner can be activated to convey important information on GOV.UK which is not deemed emergency-level information. Unlike the emergency banner, we show a user the global banner no more than 3 times, by storing the view count in a cookie.
The content of the global banner is contained in
app/views/components/_global_bar.html.erb
in Static.
Activate the global banner
In app/views/components/_global_bar.html.erb
:
- Update the variables
title
,title_href
,link_href
andlink_text
with the relevant info where applicable, otherwise set them tofalse
. - Change the value of
show_global_bar
totrue
. - Optional: set the
always_visible
boolean totrue
if the banner should not disappear after being seen 3 times. - Deploy Static. See the guidance on deploying Static.
Timed Updates
If you know about banner changes in advance and need the updates to show at a
certain time that’s not plausible to do manually (for instance, voter id banners for
a general election turning off as the polls close, or banner changes on a weekend),
you can instead use a timed update. Use the helper method before_update_time?
in
app/views/components/_global_bar.html.erb
to specify what the values for the
banner should be before and after the time. example
This utility function handles timezone issues so that deployment will work correctly in either GMT or BST.
Exclude specific pages from showing the banner
The target page linked to from the banner will automatically not show the banner.
To prevent other pages from showing the banner, add them to urlBlockList
in
app/assets/javascripts/global-bar-init.js
in Static.
Update the global banner version
The number of times a user has viewed the banner is stored in a
global_bar_seen
cookie. Once the view count reaches 3, that user will not see
that banner again, even if new banner content is deployed.
The user will only see the banner again after the third time if either:
- their
global_bar_seen
cookie expires, or - the
version
field in their cookie differs from the value ofBANNER_VERSION
inglobal-bar-init.js
To show the global banner again for all users including those who have already seen it 3 times:
- Increment the value of
BANNER_VERSION
inglobal-bar-init.js
. - Deploy Static.
Remove the global banner
- In
app/views/components/_global_bar.html.erb
, change the value ofshow_global_bar
tofalse
. - Deploy Static.
Troubleshoot the banner
- Check that your rollout of Static succeeded, for example by checking when Static was last synced in Argo CD (staging, production).
- Make sure you are looking at the same environment where you deployed your change to Static.
- Use a fresh private/Incognito window so that your testing is not affected by browser state such as cookies or cache.
- Wait 5–10 minutes for caches to expire, then repeat the previous step.
If the banner is still not showing, there may be a bug or misconfiguration somewhere. You might be able to work around the problem temporarily until the underlying issue is fixed.
- Try clearing the frontend memcache. Log into the AWS web console for the appropriate environment, find frontend-memcached-govuk under Elasticache, Memcached clusters and press the Reboot button. The UI will ask you to confirm the request.
- Consider clearing the page from the CDN cache. Most pages expire from the CDN cache within 5 minutes so this is unlikely (though not impossible) to be the issue.