Does the Json-LD custom tag support dynamic retrieval of the website name and Logo from the `system` tag?

As an experienced website operation expert, I am well aware of the importance of search engine optimization (SEO) in the current situation, and structured data, especially Json-LD, is undoubtedly the key to improving the understandability and search ranking visibility of website content. Today, let's delve into a common problem encountered by AnQiCMS users:Does the Json-LD custom tag support dynamic retrieval?systemWhat are the website name and Logo in the tag?

Overview of Json-LD support in AnQi CMS

First, let's briefly review the role of Json-LD in AnQi CMS.Json-LD is a lightweight data format that allows webmasters to describe page content in a standardized way to search engines, such as whether the website is an "Organization", an "Article", or a "Product", and so on.This is crucial for search engines to understand the context of a page and generate rich media search results (Rich Snippets).

AnQi CMS as a SEO-friendly content management system naturally integrates support for Json-LD. Through its provided{% jsonLd %}...{% endjsonLd %}Custom tag, users can flexibly insert or modify structured data in the template.This flexibility is the foundation for exploring dynamic information acquisition.The design philosophy of AnQi CMS is to allow content operators to have more freedom in controlling the front-end display, which means it usually provides mechanisms to link data between different tags.

systemTag: The dynamic source of the core information of the website

In the AnQi CMS template system,systemTags play a core role, allowing us to conveniently access the global configuration information of a website. This information is usually configured in the "Global Function Settings" backend, including but not limited to the website name (SiteName)、website logo (SiteLogo)、Website Home Address(BaseUrl) and so on.

For example, in our template, we can easily obtain the website name and Logo in the following way:

{# 获取网站名称 #}
<span>网站名称:{% system with name="SiteName" %}</span>

{# 获取网站Logo并显示 #}
<img src="{% system with name="SiteLogo" %}" alt="{% system with name="SiteName" %}" />

The strength of these tags lies in their ability to dynamically extract the latest configuration from the background database, without manually modifying the template code, which greatly improves the efficiency of website maintenance.Whether we can bring this dynamism into the structured data of Json-LD?

Dynamic fusion: Json-LD custom tags withsysteminformation联动

The good news is that the design philosophy of Anqi CMS fully considers this flexibility, and the answer is definitely yes!Json-LD custom tags fully support dynamic retrievalsystemThe website name and logo in the tag.

The principle of implementation lies in the template rendering process of Anqi CMS. When the system encounters{% jsonLd %}When a label is encountered, it will not immediately treat its content as a pure JSON string, but will first parse and replace the variables and tags contained in it. This means that we can{% jsonLd %}Use the default template variable output syntax inside the block{{ 变量名 }}To embed bysystemTags or other ways to obtain dynamic data.

In order to better organize the code and avoid embedding complex tag calls directly in the Json-LD structure, we usually adopt a clearer practice method: first,systemThe value obtained from the tag is assigned to a temporary variable (using{% set %}or{% with %}Label), then embed these temporary variables into the Json-LD structure. This not only makes the code more readable and maintainable, but also conforms to good practices in front-end development.

Demonstration of practice: Building dynamic Schema.org structured data for organizations

Now, let's demonstrate how to achieve this dynamic integration through a specific example in AnQi CMS.Assuming we want to add a Schema.org "Organization" type structured data to the homepage of the website, which includes the dynamic name and Logo of the website.

{# 首先,我们利用 system 标签获取动态的网站名称和Logo,并赋值给临时变量 #}
{% set siteName = system("SiteName") %}
{% set siteLogo = system("SiteLogo") %}
{% set baseUrl = system("BaseUrl") %}

{% jsonLd %}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "Organization",
  "name": "{{ siteName }}", {# 这里动态嵌入网站名称 #}
  "url": "{{ baseUrl }}",
  "logo": "{{ siteLogo }}", {# 这里动态嵌入网站Logo地址 #}
  "sameAs": [
    {# 您可以在这里添加社交媒体链接等,同样可以动态获取或硬编码 #}
    "https://www.facebook.com/yourpage",
    "https://twitter.com/yourhandle"
  ],
  "contactPoint": {
    "@type": "ContactPoint",
    "telephone": "{% contact with name='Cellphone' %}", {# 动态获取联系电话 #}
    "contactType": "customer service"
  }
}
</script>
{% endjsonLd %}

In the code above, we clearly demonstrated how to{% set %}tosystemTags retrieved from comments.SiteName/SiteLogoas well asBaseUrlstore as template variables. Subsequently,{% jsonLd %}Within the block, we use it just like a regular template variable, through{{ siteName }}and{{ siteLogo }}Embed dynamic information into the JSON structure of Json-LD.Even, we also demonstrated how to dynamically obtain contact information, further demonstrating the template联动 ability of Anqi CMS.

This method not only ensures the accuracy and timeliness of structured data, but also greatly reduces the burden on content operation personnel when manually updating Json-LD code due to changes in website information.No matter how the website name or logo changes, as long as it is updated in the background "Global Function Settings", the Json-LD data on the front-end will synchronize automatically, ensuring that search engines always obtain the latest website information.

Summary

Anqi CMS dynamically acquires in Json-LD custom tagssystemThe function of the label on the website name and Logo, fully reflecting its deep consideration in content management and SEO optimization.By this flexible template mechanism, we can easily build dynamic, accurate, and easy-to-maintain structured data, laying a solid foundation for the performance of the website in search engines.


Frequently Asked Questions (FAQ)

  1. What other information can I dynamically retrieve in Json-LD, apart from the website name and Logo?Of course! You can dynamically obtain any data provided by an enterprise CMS template tag using similar logic, such as through{% archiveDetail %}Tag to get the title, author, publish date, image information of the current article, or through{% categoryDetail %}Get the relevant data of the category page. The key is to first use the corresponding tag to get the required data, and then assign it to the template variable, and then{% jsonLd %}reference these variables within the block.

  2. {% jsonLd %}Where should the tag be placed in the template?Technically, you can use it at any position in the template{% jsonLd %}Tags, but for **SEO practices, structured data in Json-LD is usually recommended to be placed on the page.<head>tag within, or follow<body>After the tags. Anqi CMS template.