【问题标题】:Google Search Console reports missing "item" in "itemListElement" in breadcrumbs in Shopware 6Google Search Console 报告 Shopware 6 的面包屑中的“itemListElement”中缺少“item”
【发布时间】:2022-07-19 18:38:53
【问题描述】:

如果导航结构中使用了没有页面的类别(则该类别在面包屑中没有链接),Google Search Console 会抱怨面包屑中缺少 item

【问题讨论】:

    标签: shopware shopware6


    【解决方案1】:

    这是 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 %}
    

    【讨论】:

      猜你喜欢
      • 2022-10-02
      • 2022-09-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-07-18
      • 2022-11-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多