【问题标题】:Remove canonical link in Magento 1.9.3.x删除 Magento 1.9.3.x 中的规范链接
【发布时间】:2019-03-03 03:48:31
【问题描述】:

我想从 html 页面(站点地图)中删除规范链接。

<link rel="canonical" href="https://www.example.com/seositemap">

我在布局中使用了以下代码,但它不起作用

<?xml version="1.0"?>
<layout version="0.1.0">
    <seositemap_index_index>
        <reference name="content">
            <block type="seositemap/map" name="map" template="seositemap/map.phtml"/>
        </reference>
        <reference name="head">
            <action method="removeItem"><type>link_rel</type><rel>canonical</rel></action>
        </reference>
    </seositemap_index_index>
</layout>

有什么想法吗?

【问题讨论】:

    标签: magento magento-1.9 canonical-link magento-layout-xml


    【解决方案1】:

    这是方法的样子

    public function removeItem($type, $name)
    {
        unset($this->_data['items'][$type.'/'.$name]);
        return $this;
    }
    

    没有 rel 参数。您应该改用“名称”。并且它的内容必须是当前链接的href

    【讨论】:

    • 规范的类型应该是什么?我使用了“link_rel”,但似乎在以后版本的 magento 中它发生了变化..
    • 类型“link_rel”在最新的 1.9.4.5 之前仍然有效
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-17
    相关资源
    最近更新 更多