How to call the backend custom Json-LD structured data in AnQi CMS template and display it?

Calendar 👁️ 69

Today, with the rich content of websites, how to make search engines understand web content more accurately and display it more friendly to users has become a key link in website operation.Structured data (usually in Json-LD format) is an important tool to achieve this goal.By embedding Json-LD code in the page, we can provide standardized information to search engines about various content such as articles, products, and reviews, thus having the opportunity to obtain richer search result displays, which is what we often call 'rich snippets' or 'rich results'.

AnQiCMS is a system focused on enterprise-level content management and understands the importance of SEO optimization.It was designed from the beginning with the application of structured data in mind, not only with built-in functionality to automatically generate basic Json-LD, but also with flexible ways for users to customize and call structured data from the backend configuration in templates according to their actual needs, ensuring that your website has a good performance in search engines.

Understand the Json-LD processing mechanism of AnQi CMS

AnQiCMS provides a very considerate mechanism for handling Json-LD structured data.After you enable the structured data feature in the background, the system will automatically generate a basic Json-LD code at the top of your website page.This code usually includes basic information such as page type, URL, title, description, etc., which is sufficient for most websites to meet daily SEO needs.

However, in some scenarios, you may need to control the content of Json-LD more finely, such as defining more specific Schema properties for specific article types, or supplementing some fields that AnQiCMS does not cover by default.AnQiCMS has fully considered this advanced customization requirement, allowing you to manually intervene, call, and expand these structured data in the template.

In AnQiCMS template call and customize Json-LD

We need to use a dedicated template tag to customize Json-LD structured data in the AnQiCMS template:{% jsonLd %}. This tag serves as a container, where you can write your own Json-LD code between the start and end tags.The intelligence of AnQiCMS lies in the fact that it will merge the Json-LD you customize with the Json-LD generated by the system by default.If there is a field conflict between the two, the field you define will override the system default field, thereby giving you ultimate control.

Let's understand this process through a simple example. Suppose you want to add a custom author information to a page and specify a particular image as part of Json-LD:

{%- jsonLd -%}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "WebPage",
  "name": "自定义页面名称,覆盖默认",
  "description": "这是自定义的页面描述,会覆盖默认的页面描述。",
  "author": {
    "@type": "Organization",
    "name": "AnQiCMS运营团队"
  },
  "image": [
    "https://您的网站域名/static/images/custom-logo.png"
  ]
}
</script>
{%- endjsonLd -%}

In this code block,{%- jsonLd -%}and{%- endjsonLd -%}Wrapped our custom<script type="application/ld+json">Label. The Json-LD code itself follows the JSON syntax, so key-value pairs, arrays, and objects must be written in strict accordance with the JSON format. It includes such asnameanddescriptionThe field will override the system default generated value, whereasauthorandimagethe field will be merged as new or updated information into the final Json-LD data. Use{%-and-%}You can remove whitespace on both sides of the tag to make the generated HTML more compact.

Combine with actual content for dynamic calls.

The power of Json-LD lies in its ability to dynamically reflect the specific information of the page content.In AnQiCMS, we can combine its rich template tags to introduce dynamic content such as document titles, images, and publication dates into the Json-LD structure, thus building more accurate and semantically meaningful data.

For example, we hope to generate a suitable one for each article on the article detail pageArticleThe Json-LD data type, which includes the title, thumbnail, publication time, author, description, and other information of the article. We can implement it like this:

{%- jsonLd -%}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "{{- archive.Title -}}", {# 调用当前文章标题 #}
  "image": [
    "{{- archive.Logo -}}" {# 调用当前文章封面首图 #}
  ],
  "datePublished": "{{- stampToDate(archive.CreatedTime, "2006-01-02T15:04:05Z") -}}", {# 格式化文章创建时间为ISO 8601格式 #}
  "dateModified": "{{- stampToDate(archive.UpdatedTime, "2006-01-02T15:04:05Z") -}}", {# 格式化文章更新时间 #}
  "author": {
    "@type": "Person",
    "name": "{%- system with name='SiteName' -%}" {# 调用后台设置的网站名称作为作者 #}
  },
  "publisher": {
    "@type": "Organization",
    "name": "{%- system with name='SiteName' -%}", {# 调用后台设置的网站名称作为发布者 #}
    "logo": {
      "@type": "ImageObject",
      "url": "{%- system with name='SiteLogo' -%}" {# 调用后台设置的网站Logo作为发布者Logo #}
    }
  },
  "description": "{{- archive.Description | truncatechars:200 -}}", {# 调用文章简介,并截取前200字 #}
  "mainEntityOfPage": {
    "@type": "WebPage",
    "@id": "{{- archive.Link -}}" {# 调用文章链接 #}
  }
}
</script>
{%- endjsonLd -%}

In this code block:

  • We usedarchive.Title/archive.Logo/archive.Descriptionandarchive.LinkDirectly get the title, cover image, description, and link of the current page.
  • stampToDateThe filter will convert Unix timestamp format toarchive.CreatedTimeandarchive.UpdatedTimeConverted to the ISO 8601 format required for Json-LD"2006-01-02T15:04:05Z"A special template used in Go language for formatting time

Related articles

How to implement complex parameter filtering conditions for the dynamic display of the `archiveFilters` tag on the front end?

In website content operation, providing users with flexible and efficient filtering functions is an important factor in improving user experience and helping users quickly locate the information they need.AnQiCMS (AnQiCMS) knows this, making it easy to dynamically display complex parameter filtering conditions on the front end through its powerful template tag system, especially the `archiveFilters` tag.### Core Function and Implementation Principle The core function of the `archiveFilters` tag is to use the custom fields of the content model

2025-11-09

How to implement the sorting display of article list by views (views desc) in AnQi CMS?

How to make a hot article on the website stand out quickly and attract more visitors' attention?This can effectively enhance user experience and is also the key to optimizing content strategy and guiding traffic.For users of AnQiCMS, it is a very practical and easy-to-operate feature to display article lists sorted by page views.The powerful template tag system of AnQi CMS allows you to easily display the most popular content on your website to users.### Core Feature Revelation: Utilize `archiveList`

2025-11-09

How to display the language switch options and hreflang tags on Anqi CMS?

Today, providing multilingual support for websites has become a basic requirement for expanding the market and serving users in different regions.AnQiCMS (AnQiCMS) is fully aware of this need, integrating powerful multilingual functionality to allow website administrators to easily achieve content internationalization.This article will discuss in detail how to effectively display language switch options on AnQiCMS sites and correctly set the `hreflang` tag to optimize the internationalization recognition of search engines.Understanding AnQiCMS' multilingual capabilities AnQiCMS is an efficient

2025-11-09

How does the `breadcrumb` tag in AnQi CMS generate and display flexible breadcrumb navigation?

When building a website, a clear and intuitive navigation system is crucial for user experience and search engine optimization (SEO).Breadcrumb navigation is a tool that can significantly improve website usability, clearly showing the user's current position on the site and providing convenient links to return to the previous level page.AnQi CMS knows this and provides a powerful and flexible `breadcrumb` tag.###

2025-11-09

How does Anqi CMS handle and display external links in content, such as adding the `rel="nofollow"` attribute?

In website operation, the management of external links is an indispensable part of content strategy and search engine optimization (SEO).Especially properties like `rel="nofollow"`, which tell search engines not to pass link weight to the linked page, are crucial for managing the link health of a website and avoiding potential SEO risks.AnQiCMS (AnQiCMS) provides multiple ways to handle and display external links in content, including automatically adding the `rel="nofollow"` attribute

2025-11-09

How to correctly display and load images on the front-end page after the website enables Webp image format?

In website operation, the speed of image loading is crucial for user experience and Search Engine Optimization (SEO).WebP is a modern image format that, with its excellent compression performance, significantly reduces file size while maintaining image quality, thus greatly enhancing website loading speed.AnQiCMS (AnQiCMS) fully understands this and has built-in support for WebP image format in its system, making it easy for users to turn it on and benefit from it.However, after enabling the WebP feature, many users may be confused: how can the front-end page correctly display and load these WebP images

2025-11-09

What basic conventions should the template files of Anqi CMS follow to correctly display the content structure?

In Anqi CMS, template files are the basis for presenting website content.It is not just a simple HTML file, but a set of blueprints that follow specific conventions and rules. Only by accurately adhering to these conventions can the system correctly parse, render, and display the structure of your website content.Understanding these basic conventions can help you customize and manage your website more efficiently, ensuring that content is presented in the way you expect to visitors.### The storage location and basic format of the template file Firstly, Anqi CMS has clear requirements for the storage location of template files

2025-11-09

How to debug template display issues in AnQi CMS, such as using the `dump` filter to print variables?

Aqy CMS template debugging: Use the `dump` filter to easily locate display problems When building a website with Aqy CMS, we sometimes encounter situations where the template content is not displayed as expected.For example, you expect to display the article title at a certain location, but it turns out to be blank;Or the list data is incomplete, the content of a custom field is always unable to be presented correctly.These issues often confuse people, because it is clear that data has been set in the background, but for some reason the front-end does not display.If one can 'penetrate' the real content of the variables in the template, it will undoubtedly greatly improve the efficiency of solving such problems

2025-11-09