【发布时间】:2022-07-19 18:38:53
【问题描述】:
如果导航结构中使用了没有页面的类别(则该类别在面包屑中没有链接),Google Search Console 会抱怨面包屑中缺少 item。
【问题讨论】:
如果导航结构中使用了没有页面的类别(则该类别在面包屑中没有链接),Google Search Console 会抱怨面包屑中缺少 item。
【问题讨论】:
这是 Shopware 6 模板中的一个错误。它在问题跟踪器中报告为NEXT-22037,但尚未修复。要修复它,请在您的插件/主题中创建一个新文件 src/Resources/views/storefront/layout/breadcrumb.html.twig 并粘贴代码:
{% sw_extends '@Storefront/storefront/layout/breadcrumb.html.twig' %}
{% block layout_breadcrumb_list %}
<ol class="breadcrumb"
itemscope
itemtype="https://schema.org/BreadcrumbList">
{% set position = 1 %}
{% for breadcrumbCategory in breadcrumbCategories %}
{% set key = breadcrumbCategory.id %}
{% set name = breadcrumbCategory.translated.name %}
{% block layout_breadcrumb_list_item %}
<li class="breadcrumb-item"
{% if key is same as(categoryId) %}aria-current="page"{% endif %}
{% if breadcrumbCategory.type != 'folder' %}
itemprop="itemListElement"
itemscope
itemtype="https://schema.org/ListItem"
{% endif %}>
{% if breadcrumbCategory.type == 'folder' %}
{{ name }}
{% else %}
<a href="{{ category_url(breadcrumbCategory) }}"
class="breadcrumb-link {% if key is same as(categoryId) %} is-active{% endif %}"
title="{{ name }}"
{% if category_linknewtab(breadcrumbCategory) %}target="_blank"{% endif %}
itemprop="item">
<link itemprop="url"
href="{{ category_url(breadcrumbCategory) }}"/>
<span class="breadcrumb-title" itemprop="name">{{ name }}</span>
</a>
<meta itemprop="position" content="{{ position }}"/>
{% set position = position + 1 %}
{% endif %}
</li>
{% endblock %}
{% block layout_breadcrumb_placeholder %}
{{ parent() }}
{% endblock %}
{% endfor %}
</ol>
{% endblock %}
【讨论】: