drupal-8 - 需要帮助从 Drupal 8 中删除规范的 rel 链接
问题描述
我需要删除链接 rel="canonical"。我从元标记模块中删除了它,我还使用了一个应该删除它但它仍然存在的模块。
我删除了 Meta Tag 模块中的所有实例,并且我还使用了应该删除它的 Disable Link Rel 模块。它还在那里。
我需要从我的网站顶部删除此链接。
解决方案
您也可以从 $variables['page']['#attached'] 数组中的 hook_preprocess_html 进行更改。你必须通过打印变量来检查
print '<pre>';print_r($variables['page']['#attached']);die;
然后检查并清空数组,如下所示: -
if($variables['page']['#attached']['html_head'][1][1] == 'canonical_url') { $variables['page']['#attached']['html_head'][1][0]['#attributes'] = array(); }
在我的情况下,打印的数组是这样的: -
Array
(
[html_head] => Array
(
[0] => Array
(
[0] => Array
(
[#tag] => meta
[#attributes] => Array
(
[name] => title
[content] => test english 1 | localhost
)
)
[1] => title
)
[1] => Array
(
[0] => Array
(
[#tag] => link
[#attributes] => Array
(
[rel] => canonical
[href] => http://localhost/leadervinu_development/drupal-8.7.3/en/node/51
)
)
[1] => canonical_url
)
推荐阅读
- python - conda install 是否仍然找不到 jupyter 实验室的模块
- javascript - 你能在没有网络工作者的情况下停止 chrome 休眠选项卡吗
- c - Linux终端中C语言中用户输入的遗忘代码
- ruby-on-rails - 急切地加载 Rails 中关联实体的子集
- hadoop - Hadoop 中 Namenode 的内存
- python - 如何在 selenium 中修复此错误:AttributeError: 'list' object has no attribute 'find_elements_by_css_selector'
- php - Yii2 之前的请求导致无限递归
- python - Pandas:将多列添加到多索引列数据框中
- php - 登录 Laravel 5.8
- java - 如何动态循环遍历数组列表并添加每个第 n 个元素