How to customize website structured data (JSON-LD) to improve search engine display?

Calendar 100

It is crucial for website content to stand out in search engine results pages (SERP) in today's highly competitive online environment.Structured data, especially JSON-LD format, is the key tool to achieve this goal.It helps search engines better understand page content, thereby giving them the opportunity to display richer and more attractive 'rich media snippets' (Rich Snippets), such as the publication date, author, rating, product price, etc., all of which can significantly increase click-through rates.

As users of AnQiCMS, we have strong flexibility to optimize the search engine display of our website.The AnQi CMS was designed with a strong focus on SEO-friendliness from the outset, including many advanced SEO tools such as Sitemap generation, keyword library management, and static rule generation.In terms of structured data, Anqi CMS also provides convenient custom functions, allowing us to accurately inform search engines about the nature of our pages based on the actual content of the website.

Familiarize yourself with the JSON-LD feature in AnQi CMS

The AnqiCMS will automatically generate some basic structured data on the page to ensure the search engine friendliness of the website.However, for users who hope to obtain more specific and rich display effects in the SERP, relying solely on the default settings may not be enough.This is when customizing JSON-LD becomes particularly important.

AnQi CMS provides a very intuitive{% jsonLd %}A template tag that allows us to embed our own JSON-LD code in website templates.The strength of this tag lies in the fact that it not only allows us to fully customize structured data, but also intelligently merges with the default data generated by Anqi CMS.This means that if our custom code conflicts with the default code generated by the system, the custom code will take precedence over the default value to achieve fine-grained control.

The core concept is to utilize the powerful template tag system of Anqi CMS, dynamically extract information from the website content, and then fill this information into the JSON-LD structure.In this way, no matter how the content is updated, the structured data can remain up-to-date without manually modifying the code on each page.

How to customize JSON-LD for different types of content

The process of customizing JSON-LD usually involves adding a block in the page's<head>area.<script type="application/ld+json">In AnQi CMS, we can add a block in the template file's{% jsonLd %}Everything is completed inside the tag.

1. For the article (Archive) page

Articles are one of the most common content types, usually suitable forArticleorBlogPostingA Schema of the type. In order for the article to display author, publication date, images, and other information in search results, we can construct JSON-LD like this:

{% jsonLd %}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "BlogPosting",
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "{{ archive.Link }}"
  },
  "headline": "{{ archive.Title }}",
  "image": [
    "{{ archive.Logo }}"
   ],
  "datePublished": "{{ stampToDate(archive.CreatedTime, "2006-01-02T15:04:05Z07:00") }}",
  "dateModified": "{{ stampToDate(archive.UpdatedTime, "2006-01-02T15:04:05Z07:00") }}",
  "author": {
    "@type": "Person",
    "name": "{% system with name='SiteName' %}" {# 或者从contact标签获取作者信息 #}
  },
  "publisher": {
    "@type": "Organization",
    "name": "{% system with name='SiteName' %}",
    "logo": {
      "@type": "ImageObject",
      "url": "{% system with name='SiteLogo' %}"
    }
  },
  "description": "{{ archive.Description|truncatechars:150|replace:'"','\\"'|safe }}" {# 描述字段可能包含引号,需要转义 #}
}
</script>
{% endjsonLd %}

We used herearchiveDetailThe tag implicitly retrieves the current article'sTitle/Link/Logo/CreatedTimeandUpdatedTime.stampToDateThe function converts a timestamp to an ISO 8601 format that meets Schema requirements. For author and publisher information, we can utilizesystemTag to retrieve website name and Logo.archive.DescriptionThe field may be long or contain HTML tags, usetruncatechars:150Truncate,replace:'"','\\"'Handle escaped double quotes,|safeEnsure that the content is output as a string.

2. For the Product (Product) page

If it is a page displaying products, we can useProductA type's Schema, and includes price, inventory, brand, etc.

{% jsonLd %}
<script type="application/ld+json">
{
  "@context": "https://schema.org/",
  "@type": "Product",
  "name": "{{ archive.Title }}",
  "image": [
    "{% if archive.Images %}{{ archive.Images[0] }}{% else %}{{ archive.Logo }}{% endif %}"
  ],
  "description": "{{ archive.Description|truncatechars:150|replace:'"','\\"'|safe }}",
  "sku": "{% archiveDetail with name='SKU' %}", {# 假设SKU是自定义字段 #}
  "brand": {
    "@type": "Brand",
    "name": "{% archiveDetail with name='Brand' %}" {# 假设Brand是自定义字段 #}
  },
  "offers": {
    "@type": "Offer",
    "url": "{{ archive.Link }}",
    "priceCurrency": "USD", {# 假设货币为美元,可根据实际情况调整 #}
    "price": "{% archiveDetail with name='Price' %}", {# 假设Price是自定义字段 #}
    "itemCondition": "https://schema.org/NewCondition",
    "availability": "https://schema.org/{% if archive.Stock > 0 %}InStock{% else %}OutOfStock{% endif %}"
  }
}
</script>
{% endjsonLd %}

On the product page, we also usearchiveThe object retrieves basic information. For SKU, brand, price, etc., we can use{% archiveDetail with name='自定义字段名称' %}or{% archiveParams %}Label to extract those custom field values defined in the AnqiCMS backend content model. For example, if the product model is definedSKUandBrandfields, we can directly call. Inventoryarchive.StockThe field can be used to determine the availability of the product.

3. For the Category (Category) page

The category page is usually a list of products or articles, which can be considered for use.CollectionPageorItemListwait for Schema type. Here we takeCollectionPageFor example:

{% jsonLd %}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "CollectionPage",
  "name": "{{ category.Title }}",
  "description": "{{ category.Description|truncatechars:150|replace:'"','\\"'|safe }}",
  "url": "{{ category.Link }}",
  "image": {
    "@type": "ImageObject",
    "url": "{% if category.Logo %}{{ category.Logo }}{% else %}{% system with name='SiteLogo' %}{% endif %}"
  }
}
</script>
{% endjsonLd %}

Here, categorythe object can easily provide classification ofTitle/DescriptionandLink. If the category has its own Logo, we use it; otherwise, we can fall back to the website's default Logo.

4. For the homepage (Homepage)

The homepage acts as the gateway of the website, usually suitable for useWebSiteandOrganizationSchema to describe the basic information and search function of the website:

{% jsonLd %}
<script type="application/ld+json">
[
  {
    "@context": "https://schema.org",
    "@type": "WebSite",
    "url": "{% system with name='BaseUrl' %}",
    "name": "{% system with name='SiteName' %}",
    "potentialAction": {
      "@type": "SearchAction",
      "target": "{% system with name='BaseUrl' %}/search?q={search_term_string}",
      "query-input": "required name=search_term_string"
    }
  },
  {
    "@context": "https://schema.org",
    "@type": "Organization",
    "name": "{% system with name='SiteName' %}",
    "url": "{% system with name='BaseUrl' %}",
    "logo": "{% system with name='SiteLogo' %}"
  }
]
</script>
{% endjsonLd %}

The JSON-LD of the homepage usually includesWebSiteType to define the search function of the site, as well asOrganizationType to describe the institution the website belongs to. This information can be obtained throughsystemtags easily.

Deployment and **Practice

  1. Determine the template location:The JSON-LD code should typically be placed on the page.<head>

Related articles

How to format timestamp data into a readable date and time format and display it?

In website operation and content management, we often need to handle various data, among which date and time information is particularly common.However, these data are often stored in a string of seemingly unordered numbers (i.e., timestamps), which is difficult for ordinary users to understand intuitively.AnQiCMS as an efficient enterprise-level content management system fully considers this user's needs, provides a concise and powerful way, helps us convert these timestamp data into a clear date and time format, and present it on the website.AnQiCMS's template engine design借鉴了 Django in English

2025-11-08

How to use `if` and `for` tags to flexibly control content display logic?

## Unlock the mysteries of AnQi CMS content display: the flexible use of `if` and `for` tags AnQi CMS is committed to providing users with an efficient and customizable content management experience.In website content operation, we often need to display different information based on different conditions, or display a series of contents in bulk.

2025-11-08

How to correctly display pagination navigation for articles or category lists?

When managing website content, whether it is an article list, product display, or other category pages, a clear and effective pagination navigation is crucial for improving user experience and search engine optimization.AnQiCMS (AnQiCMS) provides powerful template tag features, allowing us to easily add correct pagination navigation to the list page.This article will introduce how to implement this feature in AnQi CMS.

2025-11-08

How to integrate and display a friend link list on a website?

In website operation, friendship links play an indispensable role. They are not only the bridges to establish contact with other websites but also effective ways to improve website authority, obtain external traffic, and enhance user experience.AnQiCMS as an efficient and flexible content management system provides an intuitive and convenient solution for the integration and display of friend links. ### First Part: Admin Friend Links One of the design philosophies of AnQiCMS is to make website operation more efficient, and the management of friend links is naturally integrated very well.

2025-11-08

How to display language switch options on the front-end page and support hreflang attributes?

AnQiCMS as an efficient and flexible content management system provides a solid foundation for users in global content promotion, and its built-in multilingual support feature is the key to achieving this goal.Display language switch options correctly on your website and configure the `hreflang` attribute for search engines, which not only greatly enhances user experience but is also an important step for international SEO optimization.### One, Preparation: Enable AnQiCMS Multilingual Functionality AnQiCMS itself has strong multilingual support capabilities

2025-11-08

How to manage and display the homepage banner carousel?

The homepage banner carousel is the face of the website, which not only attracts the attention of visitors in the first place, but also an important carrier for conveying brand information and promoting core products or services.In AnQiCMS, managing and displaying the homepage banner carousel is a straightforward and flexible process, allowing you to easily create an eye-catching visual focus for your website. ### One, manage your Banner content in the background To manage the homepage Banner carousel, you first need to log in to the AnQiCMS backend management interface. Usually

2025-11-08

How to safely display HTML or JS code in a template without escaping?

In AnQi CMS template development and content operations, sometimes we need to directly display HTML code or run JavaScript scripts on the page, rather than have them parsed by the browser as plain text.This usually occurs when it is necessary to embed third-party statistical code, advertisement scripts, or when displaying code examples in article content.However, AnQi CMS, for security reasons, defaults to escaping the content output to templates to prevent security vulnerabilities such as cross-site scripting (XSS).To safely display HTML or JS code in a template without being escaped

2025-11-08

How to truncate long text and display an ellipsis?

In website content presentation, we often need to refine some long text content, such as displaying abstracts on article list pages or showing brief descriptions on product cards.If the entire content is displayed directly, it may not only destroy the neat layout of the page, but may also affect the efficiency of users in quickly browsing information.Therefore, truncating long text and adding an ellipsis at the end has become a common strategy to improve user experience.AnQi CMS as an efficient content management system, built-in flexible template filters, can help us easily achieve this function

2025-11-08