Google Search Console抱怨如果在导航结构中使用没有页面的类别(该类别在面包屑中没有链接),则在面包屑中缺少item
。
这是Shopware 6模板中的一个错误。在issue跟踪器中报告为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 %}