As an expert deeply familiar with website operations, I know that in today's information explosion, how to make our website content better understood and presented by search engines is the core of attracting traffic and enhancing brand influence.While Json-LD is an important form of structured data, it is an indispensable tool for achieving our goals.

AnQiCMS with its flexible content model and powerful template engine provides a solid foundation for building various types of websites. Today, let's delve into a skill often overlooked in improving the SEO performance of AnQiCMS websites, yet it is crucial: how to cleverly reference in Json-LDmoduleDetailTags to dynamically obtain information about the content model.

I. The convergence of Json-LD and AnQiCMS content model value

Let's briefly review the value of Json-LD.Json-LD (JavaScript Object Notation for Linked Data) is a data format based on JSON, used to embed structured data in web pages.This data can help search engines better understand the meaning of web page content, and may be displayed in search results in the form of 'Rich Media Summary' (Rich Snippets), such as displaying star ratings, product prices, article publication dates, etc., thereby significantly increasing click-through rates.

One of AnQiCMS's core advantages lies in its 'flexible content model' feature.It allows us to customize various content types according to business needs, such as 'article model', 'product model', 'case model', etc.Each model can have its own unique fields, which allows AnQiCMS to adapt to diverse content structures.These models are not only the foundation of content organization, but also carry important metadata, such as the name of the model, description, URL alias, and so on.This metadata is the valuable source of information for us to build Json-LD structured data.

Imagine that if our website is about travel products, we might have a content model named "Travel Routes".In Json-LD, declaring this as a “Product” or “Service” type allows dynamically referencing the name, description, and even the unified entry link of this model, which is undoubtedly more flexible and intelligent than hardcoding this information and more in line with the operation requirements of dynamic websites.

Second,moduleDetailTags: The 'extractor' of model information.

In the AnQiCMS template system,moduleDetailThe tag plays the role of a special 'extractor' used to obtain detailed information about the content model.It allows us to easily access the metadata of any content model in the template without directly interacting with the database, greatly simplifying the template development process.

moduleDetailThe basic usage of tags is{% moduleDetail 变量名称 with name="字段名称" id="模型ID" %}. Among them,变量名称It is an optional parameter, if specified, the obtained model information can be assigned to the variable for subsequent reuse;nameThe parameter specifies the model properties we want to retrieve and;idortokenThe parameter is used to explicitly specify which model's information. In a multi-site environment, we can also go throughsiteIdThe parameter specifies the model information of the site.

moduleDetailTags can provide us with the following key model information:

  • Model ID (Id): The unique identifier of the model.
  • Model title (Title): The name displayed in the background, for example, "Article Model", "Product Model".
  • Model name (Name): The internal system name of the model, usually lowercase letters, may be used for internal identification or URL construction.
  • Model keywords (Keywords): Model-related keywords, can be used in Json-LD'skeywordsProperty.
  • Model introduction (Description): A brief description of the model, very suitable for use in Json-LD'sdescriptionProperty.
  • Model link (Link): The unified link pointing to the homepage or list page of the model, which can be used in Json-LDurlProperty.
  • Model table name (TableName): The database table name storing the model content.

By these fields, we can dynamically and flexibly inject information at the model level into the Json-LD structure, rather than manually writing it each time.

Third, tomoduleDetailIntegrated into the practice of Json-LD

AnQiCMS provided for us{% jsonLd %}Label, this is a very thoughtful feature. It allows us to embed JSON-LD JSON code directly in the template, and the system will automatically handle it<script type="application/ld+json">The package, more importantly, it can also intelligently merge the Json-LD we customize with the default Json-LD generated by the system, ensuring that the structured data output is complete and conflict-free.If the same named field exists, the custom content will override the system default value, which gives us great flexibility.

Now, let's look at a real example to see how to convertmoduleDetailwith the tag and{% jsonLd %}Combining tags to dynamically generate Json-LD data for a specific content model on a website. Assuming we have a content model named "product model", we want to display it in the product list page or detail page by usingWebSiteorOrganizationDeclare some general information about the model type.

”`twig {% Ld %}