How To Add Custom Notices to Page Top in Magento 2

Method 1:

Create new widget by

  1. go to CONTENT > Widgets and add widget

  2. Choose your theme and type: CMS Static Block

  3. In layout updates

Display on: All Pages

Container: Page Top

enter image description here

  1. In Widget Options select your static block which contain your discount message

Method 2:

Override notices.phtml in your theme.

From

vendor/magento/module-theme/view/frontend/templates/html/notices.phtml

To your theme

app/design/frontend/Vendor/theme/Magento_Theme/templates/html/notices.phtml

Now create static block from admin and enter your discount message. Then call this static block in notices.phtml file to show your discount notice at top of the site

<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('block_identifier')->toHtml();?>

AFAIK, we can use Widget: CONTENT > Widgets. Choose CMS static Block type. In the Layout Updates. Choose Page Top container (need to test again, not test yet): enter image description here