Does the `Json-LD` custom tag support fetching data from the `diy` custom content tag?

Calendar 👁️ 51

As an experienced website operations expert, I am well aware of the importance of structured data, especially Json-LD, in the context of increasingly refined search engine optimization (SEO) and its impact on the visibility and rich presentation of website content.AnQiCMS (AnQiCMS) is a highly efficient and flexible content management system, which naturally also provides us with powerful tools to achieve this goal.

Today, let's delve deeply into a problem that often occurs in actual operation:Json-LDDoes the custom tag support fromdiyCustom content tag to retrieve data?In short, the answer is affirmative.The design philosophy of AnQi CMS is flexibility and customization, its template engine allows for nested use of tags, thereby achieving more complex and dynamic data integration.

The importance of Json-LD and the flexible foundation of Anqi CMS

Before we delve into the details, let's review the value of Json-LD.Json-LD is a lightweight data interoperability method based on the JSON format, which helps search engines better understand the meaning of web content, such as the author of an article, publication date, product price, review ratings, and more.By embedding Json-LD code in a webpage, a website can obtain richer search result displays (Rich Snippets), thereby increasing click-through rates and traffic.

AnQi CMS is a CMS based on Go language development, with its powerful content model, customizable fields, and Django-like template engine syntax, which provides us with highly customized content publishing capabilities. Whether it is global system settings (such as company contact information), customized properties of specific content models (such as articles or products), or general customizable content (viadiyLabel management), AnQiCMS can easily call its built-in template tags.This data call flexibility is the key to our implementation of dynamic Json-LD structured data.

ExploreJson-LDCustom tag

Anqi CMS built-injsonLdCustom tags allow us to directly define Json-LD code blocks in templates. The basic usage is as shown in the document:

{% jsonLd %}
<script type="application/ld+json">
{
	"author": "AnQiCMS",
	"image": [
		"https://en.anqicms.com/anqicms.png"
	]
}
</script>
{% endjsonLd %}

The cleverness of this tag lies in the fact that it is not simply outputting static JSON-LD code. The document mentions, 'You just need to wrap the content in'}]{...}Enter the custom field you need to write, Anqi CMS will automatically merge and process the data, and if the field you define conflicts with the default field, the default field will be overridden.This sentence implies the dynamic nature of its internal processing, that is, it can parse and merge the content we provide.

The strength of the AnQiCMS template engine lies in,it supports nested use of tags. This means that we can completely usejsonLdwithin the tag,<script>In the block, continue to use other AnQiCMS template tags to dynamically retrieve data.

FromdiyCustom content tags to retrieve data and integrateJson-LD

diyCustom content tags are a very useful feature in AnQiCMS, allowing us to flexibly add global or site-specific custom parameters in the background, such as customer service phone numbers, company unified email addresses, and specific announcement texts, etc.This information often needs to appear in multiple places on the website, including in Json-LD.

Suppose we pass through the backgrounddiyCustom content set a namedCustomerServicePhoneThe parameter is used to store the company's customer service phone number. If we want to mark the website as a "Organization" type in Json-LD and include this customer service phone number, we can do it like this:

{% jsonLd %}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "{% system with name='SiteName' %}", {# 调用系统设置中的网站名称 #}
  "telephone": "{% diy with name='CustomerServicePhone' %}", {# 从diy自定义内容中获取客服电话 #}
  "url": "{% system with name='BaseUrl' %}" {# 调用系统设置中的网站基础URL #}
}
</script>
{% endjsonLd %}

In this example,{% diy with name='CustomerServicePhone' %}The tag is ingeniously embedded in the JSON structure of Json-LD. When AnQiCMS renders the page, it will first parsediyLabel, obtain the customer service phone number configured on the backend, and then insert the phone number as a string intotelephonethe field value, finally generating the complete Json-LD code.

Content model custom field withJson-LDthe combination of

except the globaldiyLabel, we often use custom fields in the content model.For example, an article may have a custom "author bio" field, and a product may have custom attributes such as "production location" or "shelf life".This information is very important structured data in Json-LD.

assuming we have an 'article model' that includes a custom fieldarticleAuthorTo store the name of the article author, and we want to reflect this in the Json-LD of the article detail page:

{# 确保在文章详情页面的上下文中使用,以获取当前文档的数据 #}
{% archiveDetail currentArticle with name="Id" %} {# 确保我们处于文档详情页的正确上下文 #}
{% jsonLd %}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Article",
  "headline": "{% archiveDetail with name='Title' %}",
  "description": "{% archiveDetail with name='Description' %}",
  "image": "{% archiveDetail with name='Logo' %}",
  "datePublished": "{{ stampToDate(archive.CreatedTime, '2006-01-02T15:04:05-07:00') }}",
  "author": {
    "@type": "Person",
    "name": "{% archiveDetail with name='articleAuthor' %}" {# 假设articleAuthor是自定义字段 #}
  },
  "publisher": {
    "@type": "Organization",
    "name": "{% system with name='SiteName' %}",
    "logo": {
      "@type": "ImageObject",
      "url": "{% system with name='SiteLogo' %}"
    }
  }
}
</script>
{% endjsonLd %}

Here, {% archiveDetail with name='articleAuthor' %}Extract the author's name directly from the custom fields of the current article. The same principle applies to other custom fields, whether they are text, numbers, links, or image URLs.

If the custom field is multiline text or rich text and may contain HTML tags, in order to meet the Json-LD pure text value requirements, we may need to use a filter to process it, for examplestriptagsRemove HTML tags, ortruncatecharsTruncate the long text to avoid Json-LD parsing errors:

”`twig {# Assume the custom field "product highlights" (productHighlights) is rich text content #} {% archiveDetail productHighlights with name=“productHighlights” %} {% Ld %} <script type=”

Related articles

How to use the `for` loop tag to generate list or array data in Json-LD (such as comment list)?

Hello everyone, website operators and partners!As an expert with many years of experience in website operation, I am well aware that how to make the website content stand out and be better understood and displayed by search engines is a crucial part of our daily work.AnQiCMS (AnQiCMS) with its powerful functions and flexible customization provides us with many conveniences.

2025-11-06

Does AnQiCMS's pseudostatic rules affect the generation of link addresses in Json-LD?

As an experienced website operation expert, I know that the SEO performance of a website is the foundation of its success.In this increasingly important era of digital content marketing, the correct use of URL structure, static page configuration, and structured data (such as Json-LD) is all affecting how search engines understand and rank website content.TodayThe answer is affirmative, and this impact is positive and crucial

2025-11-06

How to use the `if` logical judgment tag to implement conditional output in Json-LD?

As an experienced website operations expert, I fully understand that how to make the website content stand out in the increasingly fierce online competition, and how to be accurately understood and effectively displayed by search engines is the top priority of our work.Structured data (Json-LD) is undoubtedly a tool to enhance website visibility and user experience.However, the content of the website changes constantly, and if Json-LD remains unchanged, it cannot fully utilize its advantages.AnQiCMS (AnQiCMS) is a content management system known for its flexibility and ease of use, deeply understanding this field.It provides a powerful template engine

2025-11-06

How to use the `stampToDate` filter to format timestamps into readable dates in Json-LD?

## AnQi CMS: Make timestamps come alive with readability using the `stampToDate` filter in Json-LD As an experienced website operations expert, I know that in today's digital marketing era, website content must not only attract users but also please search engines.AnQiCMS (AnQiCMS) is an enterprise-level content management system developed based on the Go language, which has become a powerful assistant for many small and medium-sized enterprises and content operation teams with its high efficiency, flexibility, and SEO-friendly features.Among the many strategies to enhance SEO performance

2025-11-06

How to add or extend Json-LD structured data for AnQiCMS's custom content model?

As an experienced website operations expert, I fully understand that in today's content-oriented era, it is particularly important to stand out among our high-quality content in search engines.Structured data, especially Json-LD, is one of the key tools for achieving this goal.It can help search engines better understand our web page content, thereby improving the display effect in search results, which is what we often call "Rich Media Search Results (Rich Snippets)."}AnQiCMS as an enterprise-level content management system based on the Go language

2025-11-06

How to obtain and display the `Tag` information of an article in Json-LD?

As an experienced website operations expert, I am well aware of the importance of structured data (Json-LD) in modern search engine optimization.It can help search engines understand web content more accurately, thereby improving the display effect of the website in search results.Today, we will delve into how to cleverly obtain and display the article's `Tag` information in Json-LD within AnQiCMS (AnQiCMS), taking your content marketing strategy to a new level.

2025-11-06

How to avoid common JSON syntax errors when customizing Json-LD?

As an experienced website operations expert, I know the core status of structured data (Schema Markup), especially Json-LD, in current search engine optimization.AnQiCMS (AnQiCMS) provides users with powerful and flexible content management capabilities while also fully considering the needs of SEO, including built-in rich SEO tools, among which is support for Json-LD.

2025-11-06

How is the loading order of Json-LD in AnQiCMS template? Will it affect the page rendering speed?

As an experienced website operations expert, I have a deep understanding of the powerful functions of AnQiCMS (AnQiCMS) and its excellent performance in content operations.Today, let's talk about an important and often misunderstood topic: the loading order of Json-LD in AnQiCMS templates and whether it will affect the page rendering speed. ### Json-LD in the elegant loading journey of AnQiCMS template First, let's clarify the positioning of Json-LD.It is a lightweight data format based on JSON

2025-11-06