0

need to add alternative link in head with current URL as Href. example

<link  rel="aletrnative" href="{current page url}" />

enter image description here

2
  • You just want to get current page url right? Commented Oct 30, 2020 at 14:06
  • yeah in /layout/default_head_blocks.xml block Commented Oct 30, 2020 at 14:09

1 Answer 1

1

As far as I know, you can add <link href="..."> by creating new phtml template.
Example:
In your_layout.xml file,

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
            <referenceBlock name="head.additional">
                <block class="Magento\Framework\View\Element\Template" template="YourCompany_YourModule::head_links.phtml" />
            </referenceBlock>
        </body>
</page>

In templates/head_links.phtml,

<link href="{your url}" />

After that, don't forget to bin/magento cache:clean. It'll work.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.