As an experienced website operations expert, I am well aware of the importance of structured data for a website's performance in search engines.JSON-LD is a mainstream way to implement structured data, which can help search engines better understand website content, thereby enhancing the display opportunities of websites in search results, such as getting rich search results (Rich Snippets).In AnQiCMS (AnQi Content Management System), we can fully utilize its powerful backend configuration functions to add criticalOrganization(Organization)andWebSite(Website)type of Json-LD data, making it clear to search engines about your website.
Why pay attention toOrganizationandWebSitetype of Json-LD?
Among the many types defined by Schema.org,OrganizationandWebSiteare the two most fundamental and core types of websites.
OrganizationTypeIt aims to describe the entity represented by your website, whether it is a company, organization, or personal brand.It typically includes the name, official website URL, Logo, contact information, and social media links.This helps search engines understand your brand identity and display more rich information in places like knowledge graphs.WebSiteTypeIt describes the website itself. It usually includes the website name, URL, and a very importantpotentialActionProperties used to define the in-site search function. This allows users to perform in-site search directly in Google search results, greatly enhancing the user experience.
AnQiCMS was designed with the general needs of website operations in mind, therefore, many of the settings in the background naturally correspond to Json-LD inOrganizationandWebSiteThe required key information.
The treasure of AnQiCMS backend: the source of information
AnQiCMS is the perfect starting point for providing data streams with Json-LD. You can find the required information in the following core settings areas:
Global feature settings (
help-setting-system.md):- Website name (SiteName):This is the formal name of your organization or website, directly corresponding to the Json-LD of
nameProperty. - Website Address (BaseUrl):The root URL of the website corresponds to
urlProperty. - Website Logo (SiteLogo):The visual identifier of the brand corresponds to
logoProperty. - Custom parameter:If you have a link to your social media (such as Facebook, Twitter, LinkedIn, etc.), although AnQiCMS does not have a dedicated social media field, we can use its flexible "custom parameter" feature to add these links in the "Global Function Settings", for example, the parameter name is
FacebookUrlThe parameter value is the link to the corresponding social media homepage. These will be used forsameAsProperty.
- Website name (SiteName):This is the formal name of your organization or website, directly corresponding to the Json-LD of
Contact Information Settings (
help-setting-contact.md):- Contact (UserName), Phone Number (Cellphone), Address (Address), Email (Email):This information is
Organizationin the typecontactPointThe key component of the (contact point) attribute.
- Contact (UserName), Phone Number (Cellphone), Address (Address), Email (Email):This information is
Home TDK settings (
help-setting-tdk.md):- Home Page Title (Title), Home Page Keywords (Keywords), Home Page Description (Description):Not directly used
OrganizationorWebSiteThe core attribute, butDescriptioncan beWebSiteas a supplement to the description, butTitleandKeywordsis crucial for the overall SEO.
- Home Page Title (Title), Home Page Keywords (Keywords), Home Page Description (Description):Not directly used
Core operation: usejsonLdlabel “assembly” structured data
AnQiCMS provided a very convenientjsonLdLabel (tag-jsonLd.mdUsed for customizing and outputting Json-LD data.The power of this tag lies in the fact that it allows you to write custom Json-LD in the template, and AnQiCMS will automatically merge this custom content with the default Json-LD generated by the system.If your custom field conflicts with the system default field, the custom field will take precedence.
This has provided us with great flexibility, we can<head>area (usuallytemplate/您的模板名/partial/header.htmlortemplate/您的模板名/bash.html)add site-level unifiedOrganizationandWebSiteJson-LD.
Now, let's see how to dynamically inject the above background information into Json-LD using template tags:
{% jsonLd %}
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@graph": [
{
"@type": "Organization",
"name": "{% system with name='SiteName' %}",
"url": "{% system with name='BaseUrl' %}",
"logo": "{% system with name='SiteLogo' %}",
"contactPoint": {
"@type": "ContactPoint",
"telephone": "{% contact with name='Cellphone' %}",
"contactType": "Customer Service",
"email": "{% contact with name='Email' %}"
// 更多联系方式可以根据后台自定义字段添加
},
"sameAs": [
// 假设您在全局设置中创建了自定义参数 FacebookUrl, TwitterUrl, LinkedinUrl
"{% system with name='FacebookUrl' %}",
"{% system with name='TwitterUrl' %}",
"{% system with name='LinkedinUrl' %}"
// 如果联系方式设置里有社交媒体字段,也可以直接使用contact标签
// "{% contact with name='Facebook' %}",
// "{% contact with name='Twitter' %}",
// "{% contact with name='Linkedin' %}"
]
},
{
"@type": "WebSite",
"url": "{% system with name='BaseUrl' %}",
"name": "{% system with name='SiteName' %}",
"description": "{% tdk with name='Description' %}", // 使用首页描述作为网站描述
"potentialAction": {
"@type": "SearchAction",
"target": "{% system with name='BaseUrl' %}/search?q={search_term_string}", // 假设您的搜索页路径为 /search
"queryInput": "required name=search_term_string"
}
}
]
}
</script>
{% endjsonLd %}
In this code block:
- We used
{% system with name='...' %}tags to obtain the website name, base URL, and Logo. {% contact with name='...' %}Tags are used to extract contact information and buildcontactPoint.- By
{% system with name='FacebookUrl' %}and other custom parameters, we can flexibly add social media links tosameAsIn the array. Make sure you have added these custom parameters in the “Global Function Settings” and filled in the correct social media links. {% tdk with name='Description' %}The tag then retrieves the description of the website homepage asWebSiteAdditional information type.potentialActionPoints to the AnQiCMS in-site search path, usually./searchAnd with.qParameter.
Place this code in the website template.<head>Inside the tag, AnQiCMS dynamically extracts the latest data from the background every time the page is rendered and generates the corresponding Json-LD structured data.This way, you don't have to touch complex code, just maintain the background information, and you can ensure that the structured data of the website remains up-to-date and accurate.
This method is extremely.