1

I had created a About US cms page from Admin panel(Content->Pages)

Now, i want to add link to this CMs page in the header of my website.

enter image description here

In the above image i want to add "About Us" link next to "CONTACT US".

This is my xml code

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
 <referenceBlock name="logo">
 <arguments>
 <argument name="logo_img_width" xsi:type="number">111</argument>
 <argument name="logo_img_height" xsi:type="number">50</argument>
 </arguments>
 </referenceBlock>
<referenceBlock name="top.links">
 <block class="Magento\Framework\View\Element\Html\Link" name="about-porto">
 <arguments>
 <argument name="label" xsi:type="string" translate="true">About Us</argument>
 <argument name="path" xsi:type="string">about-porto</argument>
 </arguments>
 </block>
</referenceBlock>
 <referenceContainer name="footer" remove="true"/>
 <referenceBlock name="report.bugs" remove="true"/>
 <referenceBlock name="catalog.compare.sidebar" remove="true"/>
 <referenceBlock name="wishlist_sidebar" remove="true"/>
</body>
asked Jun 28, 2019 at 4:31
6
  • Could you share your xml code .. Commented Jun 28, 2019 at 4:41
  • Have u try my answer ? ? Commented Jun 28, 2019 at 12:12
  • @Magento_Bhurio ....No, its not working Commented Jun 29, 2019 at 4:21
  • @aravind. Tried your code too, its not working....See my edited post i have added my default.xml file Commented Jun 29, 2019 at 4:24
  • Please Try My Updated answer. Commented Jun 29, 2019 at 4:45

2 Answers 2

1

In your xml file add follwoing code to display about us link,

<referenceBlock name="header.links">
 <block class="Magento\Cms\Block\Block" name="block_identifier">
 <arguments>
 <argument name="block_id" xsi:type="string">block_identifier</argument>
 </arguments>
 </block>
 </referenceBlock>
answered Jun 28, 2019 at 4:51
3
  • Yes your solution worked....Thanx Commented Jun 29, 2019 at 4:39
  • You are welocme.. Commented Jun 29, 2019 at 6:27
  • I think i missed to change header.links to top.links Commented Jun 29, 2019 at 6:29
1

Please look at here it's simple Your xml Page Shold Like this one in your custom theme, please add this code in this file :-

project/app/design/frontend/Magento/ThemeName/Magento_Theme/layout/defualt.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
 <referenceBlock name="logo">
 <arguments>
 <argument name="logo_img_width" xsi:type="number">111</argument>
 <argument name="logo_img_height" xsi:type="number">50</argument>
 </arguments>
 </referenceBlock>
 <referenceBlock name="header.links">
 <block class="Magento\Framework\View\Element\Html\Link" name="about-us">
 <arguments>
 <argument name="label" xsi:type="string" translate="true">About Us</argument>
 <argument name="path" xsi:type="string">about-porto</argument>
 </arguments>
 </block>
 </referenceBlock>
<referenceContainer name="footer" remove="true"/>
<referenceBlock name="report.bugs" remove="true"/>
<referenceBlock name="catalog.compare.sidebar" remove="true"/>
<referenceBlock name="wishlist_sidebar" remove="true"/>
</body>
Nafsss
75815 silver badges50 bronze badges
answered Jun 28, 2019 at 4:54

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.