In today's highly competitive online environment, every detail of a website may affect its performance in search engines.As an experienced website operations expert, I am well aware of the crucial role that structured data (Structured Data) plays in enhancing website visibility, and Json-LD, as the format recommended by search engines like Google, is of utmost importance.Especially for corporate websites, how to accurately and dynamically display a company's contact information, such as phone numbers and addresses, can not only enhance local search visibility but also significantly increase user trust.

Today, we will delve into how to cleverly reference the background in Json-LD dynamically in AnQiCMS (AnQi CMS)contactContact information configured in the tag.AnQiCMS provides great convenience for content operation with its high efficiency and customizable features, and this dynamic reference mechanism is a microcosm of its flexibility.

Json-LD and Contact Information: The Foundation for Enhancing Website Trust

Let's briefly review the importance of JSON-LD.It is a data format based on JSON, allowing website owners to embed structured data directly into web pages.These data are not visible to users, but can be understood by search engine robots, thereby helping search engines better interpret web content.

For enterprises, presenting core contact information (such as company name, phone number, physical address, business hours, etc.) in the form of JSON-LD is an effective way to build a digital identity for the enterprise.This not only helps search engines display richer snippets (Rich Snippets) in search results, such as directly showing company phone numbers or map information, but also subtly conveys the professionalism and trustworthiness of the enterprise.Imagine how much easier it would be for users to click and contact you if they directly see your company's phone number and address in the search results?

How does AnQiCMS manage your enterprise contact information?

AnQiCMS knows the importance of managing corporate contact information, and therefore provides the 'Contact Information Settings' feature on the backend. Here, you can centrally configure the company's various contact information, such as:

  • Contact Person (UserName)
  • Contact Phone (Cellphone)
  • Contact Address (Address)
  • Contact Email (Email)
  • WeChat (Wechat) and WeChat QR Code (Qrcode)
  • and various social media links (such as WhatsApp, Facebook, Twitter, etc.)

Even, AnQiCMS also allows you to customize more contact information fields according to your business needs. Once this information is configured in the background, it can be flexibly called on the front-end page through AnQiCMS's powerful template tag system, with the most commonly used beingcontactLabel. For example, you can{% contact with name="Cellphone" %}get the phone number set in the back end directly.

Core issue: How to dynamically reference these contact methods in Json-LD?

Now, the key issue comes: We already know how to centrally manage contact information in the AnQiCMS backend, and we also know how to access it throughcontactTags are called in the content of ordinary pages.How can these dynamic data be seamlessly integrated into the Json-LD structured data, rather than manually modifying the Json-LD code each time the phone number or address is changed?

Maintaining JSON-LD manually is not only inefficient but also prone to errors, especially when managing multiple sites or frequently updating contact information.The advantage of AnQiCMS lies in the flexibility of its templates, which is enough to meet this demand.

Solution:jsonLdTags andcontactThe perfect combination of tags

AnQiCMS provides a namedjsonLd[en]A dedicated tag that allows you to customize the JSON-LD content of the page. The core of solving dynamic reference contact information is right here.jsonLdInside the tag, using AnQiCMS template syntax, combinedcontacttag to obtain the background configuration data.

jsonLdThe usage of the tag is relatively intuitive. It acts as a block-level tag where you can write JSON code that conforms to the JSON-LD specification. AnQiCMS will intelligently handle these contents and output them to the page.<head>Area (usually).

Here is a specific code example demonstrating how to dynamically reference backend-configured contact information in Json-LD:

{% jsonLd %}
<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "LocalBusiness",
  "name": "{% system with name='SiteName' %}",
  "image": "{% system with name='SiteLogo' %}",
  "telephone": "{% contact with name='Cellphone' %}",
  "address": {
    "@type": "PostalAddress",
    "streetAddress": "{% contact with name='Address' %}",
    "addressLocality": "您的城市", {# 假设城市信息需要单独填写或从其他地方获取 #}
    "addressRegion": "您的省份", {# 假设省份信息需要单独填写或从其他地方获取 #}
    "postalCode": "100000", {# 假设邮政编码需要单独填写或从其他地方获取 #}
    "addressCountry": "CN"
  },
  "url": "{% system with name='BaseUrl' %}",
  "openingHours": "Mo,Tu,We,Th,Fr 09:00-18:00", {# 假设营业时间需要单独填写 #}
  "contactPoint": {
    "@type": "ContactPoint",
    "telephone": "{% contact with name='Cellphone' %}",
    "contactType": "customer service"
  }
}
</script>
{% endjsonLd %}

Code analysis and practical tips:

  1. {% jsonLd %}...{% endjsonLd %}This is the Json-LD custom tag block provided by AnQiCMS, all your custom Json-LD content should be placed here.
  2. @contextand@typeThis is the foundation of JSON-LD.@contextIt defines a vocabulary of data semantics (usually Schema.org),@typewhich indicates the type of the entity you are describing, for exampleLocalBusiness(Local Merchant) orOrganization(Organization).
  3. "name": "{% system with name='SiteName' %}"Here we not only refer to the contact information, but also dynamically refer to the website name (SiteName) and website logo (SiteLogo) configured in the background "Global Function Settings" as the enterprise name.This demonstrates the collaborative ability of various tags in AnQiCMS.
  4. "telephone": "{% contact with name='Cellphone' %}": This is the core! We directly go throughcontacttags, toname='Cellphone'Parameters, dynamically obtained the phone number configured in the "Contact Information Settings" on the backend.If the phone number is updated, you only need to modify it once in the background, and all Json-LD structured data that references this tag will be automatically updated.
  5. "address": {...}: Similarly, we go through{% contact with name='Address' %}Dynamically obtained the company's detailed address. Please note, Schema.org'sPostalAddressThe type requires a more detailed address breakdown (such as street, city, province, postal code, country), if your backend only provides a complete address, you may need to manually split it or add more detailed address fields in the backend for this call.
  6. |safeFilterIn some cases, when Json-LD content contains special characters or HTML entities, AnQiCMS template engine may automatically escape them to ensure safety. AlthoughjsonLdThe tag content usually has built-in processing, but if you encounter Json-LD parsing errors, you can try adding after the dynamic content output|safeFilter, for example{{ someVar|safe }}To ensure that the content is output as is without escaping. However, for JSON-LD, which is a plain text JSON format, it is usually not necessary.|safe.

Operation steps and precautions:

  1. Back-end configuration is completeEnsure that the relevant information in the "Contact Information Settings" and "Global Function Settings" of AnQiCMS back-end is filled in completely and accurately.
  2. Select a template fileAdd the above Json-LD code to the public header file of your website template (for examplebase.htmlorheader.htmlwhich is usually<head>inside the</head>tag), so that it can take effect on all pages.
  3. JSON-LD ValidationAfter adding code, be sure to use Google's Structured Data Testing Tool or Rich Results Test to verify your webpage.This can help you check for syntax errors in Json-LD code, as well as whether search engines can correctly parse your data.
  4. Adjust as needed: Example ofLocalBusinessType is just one of them, you can adjust according to your business type (such asOrganization/Restaurant/ServiceChoose a more appropriate Schema.org type and add more relevant fields, such as business hours (openingHours), price range (priceRange), geographical coordinates (geo)et al. This information can also be obtained dynamically through backend custom fields and tags.contactorsystemLabel to dynamically retrieve.

Summary

AnQiCMS provides a powerful and flexible template system that allows website operators to easily manage content and optimize SEO. Through a clever combinationjsonLdTags andcontactandsystemWith these tags, we can not only dynamically reference contact information, but also ensure that the structured data of the website is always synchronized with the background configuration, greatly enhancing operational efficiency and the website's search engine friendliness.This 'one-time configuration, use anywhere' strategy is a reflection of AnQiCMS in helping small and medium-sized enterprises and content operation teams improve their competitiveness.

Common Questions (FAQ)

Q1: Can a reference be made in Json-LD tosystemthe website name or Logo information configured in the tag?A1: Absolutely. As shown in the article example, you can use{% system with name='SiteName' %}Fetch the website name dynamically, or use{% system with name='SiteLogo' %}Get the website logo address. AnQiCMS'ssystemThe label can call all configuration items from the "Global Function Settings" on the backend, allowing the basic site information in Json-LD to be dynamically updated as well.

Q2: What will be displayed in Json-LD if I have not configured a contact method in the background (for example, if I have not filled in WhatsApp)?A2: If a contact information field is empty in the background,contactThe output at this location will also be an empty string. In Json-LD, this usually appears as the value of the field being an empty string (for example"telephone": ""

Q3: BesidesOrganizationorLocalBusinessWhat are some Json-LD types that can apply this dynamic reference method?A3: This dynamic reference method is suitable for all Json-LD types that need to include contact information (or any other information that can be obtained through AnQiCMS tags). For example,Article(Article) Type, you can dynamically refer topublisher(Publisher)'snameandlogo; InProduct(Product) Type, you can refer toseller(Seller)'s contact information. The core principles arejsonLdInside the tag, use AnQiCMS template syntax (such ascontact/systemetc. tags) to dynamically fill in the corresponding Json-LD attribute values.