As an experienced website operations expert, I am well aware that it is crucial to understand how to make our website content better understood and presented by search engines in an increasingly competitive online environment.Structured data (JSON-LD) is a powerful tool at our disposal, helping search engines parse page information more accurately, thereby giving us the opportunity to display richer search results and attract more users' attention.
Today, let's delve into a topic that is of great concern to AnQiCMS users: how to cleverly integrate the core information of category details in AnQiCMS, such as category names, descriptions, etc., into JSON-LD to optimize the performance of our category pages in search engines.
Embrace JSON-LD: Why does the category page need it?
In a powerful content management system like AnQiCMS, the category page often carries a large number of links to articles, products, and other content, which is an important hub for user navigation and information discovery.However, search engines may only treat these pages as a common list page when crawling them.If we can clearly tell search engines about a category page of a certain topic using a standard format like JSON-LD, including its name, description, and so on, then search engines can better understand the theme and structure of the page. This is undoubtedly a huge help in improving the SEO effect of the category page, such as displaying more relevant 'rich media summaries (Rich Snippets)' in search results.
AnQiCMS is a system that highly focuses on SEO optimization and provides flexible content solutions, its built-in functions provide a solid foundation for us to achieve this goal.From pseudo-static management to advanced SEO tools, AnQiCMS has always been committed to helping users stand out in search engines.And customizing JSON-LD is exactly the key step to pushing this optimization ability to a deeper level.
The way of integration of AnQiCMS JSON-LD: flexible and powerful coexist
AnQiCMS understands the importance of structured data and therefore provides very flexible JSON-LD customization capabilities in the system.It does not simply help you generate a static JSON-LD, but allows you to fine-tune it at the template level according to specific needs.This design concept allows us to fully utilize the AnQiCMS template tags to seamlessly integrate the dynamic data of category details into the JSON-LD structure.
The core integration mechanism lies in the AnQiCMS provided{% jsonLd %}The tag allows us to define custom JSON-LD data, and AnQiCMS will intelligently merge it with the default JSON-LD data that may already be on the page.This means that we can enjoy the basic structured data automatically generated by the system, and also add more personalized and precise data on this basis, such as for specific pages (such as category detail pages).
Step one: Understand the source of classified data
To integrate category information into JSON-LD, we first need to clarify how to obtain these data from AnQiCMS. Fortunately, AnQiCMS provides{% categoryDetail %}Labels, they can help us easily get the details of the current category or a specified category.
When we are on a category detail page,{% categoryDetail %}Labels can be automatically identified and retrieve the data of the current category without any additional parameters. We can specify the specific fields to be retrieved usingnameattributes, for example:
- Category Name:
{% categoryDetail with name="Title" %} - Category link:
{% categoryDetail with name="Link" %} - Category description:
{% categoryDetail with name="Description" %} - Category thumbnail/Logo:
{% categoryDetail with name="Logo" %}or{% categoryDetail with name="Thumb" %}
The values of these fields will become the key elements in constructing JSON-LD.
Step two: Refine the JSON-LD structure.
Next, we will utilize{% jsonLd %}Tags and{% categoryDetail %}tags to build a JSON-LD structure suitable for category pages. For category pages,CollectionPageorWebPageand usingaboutThe property to describe the page theme is a common Schema type. Here we takeCollectionPageFor example, it can well express the meaning of a collection page (such as an article list page, product classification page).
Assuming we want to add the category name, description, URL, and possibly the category logo information to the JSON-LD, we can do so in the AnQiCMS category list template (for example{模型table}/list.htmlor{模型table}/list-{文档分类ID}.htmlAdd the following similar code:
{% jsonLd %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "CollectionPage",
"name": "{% categoryDetail with name='Title' %}",
"description": "{% categoryDetail with name='Description'|striptags|truncatechars:150 %}", {# 确保描述是纯文本且长度适中 #}
"url": "{% categoryDetail with name='Link' %}",
{%- set categoryLogo = categoryDetail.Logo %} {# 获取Logo,如果不存在可尝试Thumb #}
{%- if categoryLogo %}
"image": "{% categoryDetail with name='Logo' %}",
{%- elif categoryThumb = categoryDetail.Thumb %} {# 如果Logo不存在,尝试Thumb #}
"image": "{% categoryDetail with name='Thumb' %}",
{%- endif %}
"mainEntity": {
"@type": "ItemList",
"numberOfItems": "{% categoryDetail with name='ArchiveCount' %}",
"itemListElement": [
{# 这里可以动态生成部分列表项的JSON-LD,例如前几个文章或产品 #}
{# 假设我们只显示前3个文章作为示例,需要根据实际页面内容调整 #}
{% archiveList archives with type="list" limit="3" %}
{%- for item in archives %}
{
"@type": "ListItem",
"position": {{ forloop.Counter }},
"url": "{{ item.Link }}",
"name": "{{ item.Title }}"
}{%- if not forloop.Last %},{% endif %}
{%- endfor %}
{% endarchiveList %}
]
}
}
</script>
{% endjsonLd %}
In this code, we:
- Define context and type:
"@context": "https://schema.org"and"@type": "CollectionPage"It is clear that this is a Schema.org collection page. - Integrate core dataThrough `{% categoryDetail with name=‘…’