magento2: add static block to header menu
-
04-10-2020 - |
Question
My Categories are displayed in my Header Main menu. Now I want to add another link( called 'about us') after the last category in my header. I plan to create a static cms block -> in it's content put some html:
<ul>
<li class="ui-menu-item level0">
<a href="#" class="level-top"><span>About Us</span></a>
</li>
</ul>
then add this static block to the header. How can I achieve this ?
Solution
Firstly you need to create static cms block about us. and add your content in content part.
Now to add that block in header follow the below steps :
- Create/Add new category from product/categories from admin menu.
- Make Sure Enable Categories menu and Include in menu is selected as enable.
- Click on Content tab and go to the Add CMS Block - Select your about us cms block from there.
- From Display settings , Select Display mode as a Statick Block only and Anchor as yes.
- Click on Save button and after that run the cache:clean command and check.
Screenshot for select static block :
Screenshot of display settings :
Note : You can also do it same thing by overriding the respected template.
OTHER TIPS
Create static block from CONTENT->BLOCKS
If you need About-Us as category link then you do not need to add from template. It would be better if you add it as category.
Go to Products->Categories
Create About-Us category
Go to the content tab from Add CMS Block select your block.
Go to the Display Setting from Display Mode select Static Block only