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.
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>
-
Could you share your xml code ..aravind– aravind2019年06月28日 04:41:01 +00:00Commented Jun 28, 2019 at 4:41
-
Have u try my answer ? ?Magento_Bhurio– Magento_Bhurio2019年06月28日 12:12:54 +00:00Commented Jun 28, 2019 at 12:12
-
@Magento_Bhurio ....No, its not workingNafsss– Nafsss2019年06月29日 04:21:41 +00:00Commented Jun 29, 2019 at 4:21
-
@aravind. Tried your code too, its not working....See my edited post i have added my default.xml fileNafsss– Nafsss2019年06月29日 04:24:39 +00:00Commented Jun 29, 2019 at 4:24
-
Please Try My Updated answer.Magento_Bhurio– Magento_Bhurio2019年06月29日 04:45:03 +00:00Commented Jun 29, 2019 at 4:45
2 Answers 2
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>
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>