How to get the title, content, and link of the current page document?

Calendar 👁️ 64

As an experienced website operator who deeply understands the operation of AnQiCMS, I know that the accuracy and efficiency of obtaining the current page content is crucial for the daily management and optimization of the website.AnQiCMS provides intuitive and powerful template tags, allowing us to easily extract the required document title, specific content, and standard link from the currently loaded page.This not only helps us achieve fine control in front-end display, but also provides a solid foundation for SEO optimization.

Get the document title of the current page

The document title of the current page usually has two levels of meaning: one is HTML<title>The page title displayed to search engines and browsers users, which is crucial for SEO; it is also the main identifier of the document or article title in the main content of the page.

for HTML's<title>tags, AnQiCMS providestdktags, we can use{% tdk with name="Title" %}A way to dynamically retrieve the title of the current page. This tag automatically generates the most appropriate title based on the type of the current page (document, category, single page, etc).It also supports throughsiteName=trueto automatically append the site name throughsepto customize the separator, andshowParent=trueParameters to display the parent category title, all of these are automatically adjusted according to the backend configuration.

When it is necessary to display the specific title of a document or article in the page content area, we can use the detail tags of a specific content type. For example, if the current page is an article or product detail page, then we usearchiveDetailtags, through{% archiveDetail with name="Title" %}You can obtain the title. Similarly, for a single page, we can use{% pageDetail with name="Title" %}; for category pages, it uses{% categoryDetail with name="Title" %}; for tag pages, it uses{% tagDetail with name="Title" %}These tags will default to the title of the current page's document, single page, category, or tag if no ID or token is specified.

This is a brief example of getting the page title:

{# 获取HTML头部标题,并附加网站名称 #}
<title>{% tdk with name="Title" siteName=true %}</title>

{# 在页面主体内容中显示文章标题 #}
<h1>{% archiveDetail with name="Title" %}</h1>

Extract the specific content of the current page

The main content of the current page is the core requirement for building dynamic web pages. The detail tag of AnQiCMS can accurately extract detailed information of various contents.

For article or product detail pages, we usearchiveDetailtags, through{% archiveDetail with name="Content" %}You can get the full content of the document. This tag is very flexible when outputting content.For example, if the content contains HTML tags, in order to ensure that they are rendered correctly rather than as plain text, it is usually necessary to accompany with|safea filter such as{{ archiveContent|safe }}. In addition, if the content includes images, we can also make use oflazy="data-src"Implement lazy loading of images with attributes to enhance page performance. When the Markdown editor is enabled on the back end, the content is automatically converted to HTML; if manual control of the conversion behavior is needed, you can userender=trueorrender=falseParameter.

Similarly, if the current page is a single page, we can use{% pageDetail with name="Content" %}to get its content; for category pages, use{% categoryDetail with name="Content" %}; for tag pages, it uses{% tagDetail with name="Content" %}. These tags also support|safeFilter and Markdown rendering control.

Here is an example of getting the content of the page:

{# 获取文章主体内容,并确保HTML正确渲染 #}
<div>
    {%- archiveDetail articleContent with name="Content" lazy="data-src" render=true %}
    {{articleContent|safe}}
</div>

Get the link address of the current page

The link address of the current page is also an indispensable part of website navigation and SEO strategy. AnQiCMS provides multiple ways to obtain the standard URL of the current page.

The most direct way is to use a specific content type detail tag. For example, for articles or product detail pages, we can through{% archiveDetail with name="Link" %}To get the absolute or relative link on the website. Similarly, for a single page, use{% pageDetail with name="Link" %}; For category pages, use{% categoryDetail with name="Link" %}; For tag pages, use{% tagDetail with name="Link" %}These links are automatically generated based on the pseudo-static rules and content structure of the current page.

In addition, for SEO, it is crucial to set up a canonical link (Canonical URL), which can inform search engines of the preferred version of the current page, avoiding duplicate content issues. AnQiCMS throughtdkThe label provides this feature, we can use{% tdk with name="CanonicalUrl" %}To obtain the specification link of the current page. In the template, we usually judge whether this specification link exists, and if it exists, we place it in the HTML's<head>Within the area.

This is an example of getting a page link:

{# 获取文章的URL,可用于导航或分享按钮 #}
<a href="{% archiveDetail with name="Link" %}">阅读更多</a>

{# 在页面头部设置规范链接 #}
{%- tdk canonical with name="CanonicalUrl" %}
{%- if canonical %}
<link rel="canonical" href="{{canonical}}" />
{%- endif %}

Through these flexible and intelligent template tags, AnQiCMS enables website operators to efficiently manage and present content, making it effortless whether it's optimizing page titles to improve search rankings, precisely controlling content display to enhance user experience, or ensuring the规范性 of page links to maintain website health.Mastering the use of these tags is the key to unleashing the potential of AnQiCMS content management.

Frequently Asked Questions

AnQiCMS detail tag (such as)archiveDetail/pageDetail/categoryDetail/tagDetail) if not explicitly specifiedidortokenWhen the parameter is set, it will automatically identify the type of content currently displayed on the page and extract the corresponding fields of the content.The system intelligently judges the core entity of the current page through URL paths, routing rules, and internal context information, thereby automatically obtaining its associated data.

You can explicitly specify in the detail tagidortokenParameters to retrieve data from non-current pages. For example, if you want to display the title of another specific article on the article detail page, you can use{% archiveDetail with name="Title" id="123" %}of which123Is the ID of the target article. In this way, you can call any specified type of data on any page to achieve more complex page layout and content aggregation.

tdkThe tag is mainly used to retrieve metadata related to the entire page, such as HTML<title>/<meta name="keywords">/<meta name="description">as well as<link rel="canonical">. This information is for the entire page rather than for a specific content item within the page. AndarchiveDetail/pageDetailTags then focus on obtaining the page inCore content entity(For example, an article or a product) has detailed fields such as its title, main content, and its own link. In practice, they work together:tdkTags are usually used in the HTML header, affecting search engine inclusion and browser display; while content detail tags are used in the main body of the page, to display the specific information that the user is browsing.

Related articles

What types of custom fields does Anqi CMS support? For example, 'Single line'

As an experienced website operator for AnQiCMS, I am well aware of the importance of the flexibility of the content management system, especially the custom field function, which can greatly meet the personalized needs of content structure and display in different business scenarios.AnQiCMS provides quite comprehensive support in this aspect, allowing us to build rich content types according to our actual needs.One of the core strengths of AnQiCMS is its flexible content model.This means that the system not only provides preset content types such as articles and products, but also gives us the power to create or modify content models according to our business characteristics

2025-11-06

What specific prompts does the 'Title Name' field of the custom content model have when publishing documents?

As an experienced website operator proficient in Anq CMS, I know that every setting of the background field may have a cascading effect on the efficiency of content operation and the ultimate user experience.In the custom content model, the 'Title Name' field, although seemingly trivial, plays a crucial guiding role in practice, greatly affecting the accuracy of content creation and the smoothness of the process.AnQi CMS, with its high flexibility and customizability, provides us with the ability to build a diverse content structure based on different business needs.No matter if it's articles, products, activities, or any other customized information type

2025-11-06

How to set the 'URL alias' of the content model to better support search engine optimization (SEO)?

As an experienced AnQiCMS (AnQiCMS) website operations personnel, I know that every detail can affect the performance of the website in search engines.The URL structure, especially the alias setting of the content model's URL, is a crucial element that should not be overlooked.A clear, meaningful, and search engine-friendly URL not only enhances user experience but is also the foundation of website SEO optimization.### How to optimize website visibility in search engines: How to set the URL alias of the content model In today's increasingly fierce digital marketing

2025-11-06

What is the difference between the 'model name' and 'model table name' in the content model? What specifications should be paid attention to when naming?

As an experienced CMS website operator, I am well aware that understanding the core concepts of the system is crucial when managing and optimizing website content.The content model is the foundation of AnQi CMS flexibility, allowing us to customize different types of content structures according to business needs.In this process, 'Model Name' and 'Model Table Name' are two concepts that are often mentioned but easily confused.Next, I will elaborate on the differences between them and the conventions to be followed in naming.

2025-11-06

How to loop and display the latest 10 articles in the template?

As an experienced CMS website operation personnel, I fully understand the core position of content in website operation.Dynamically displaying the latest content can not only improve the user experience, but also effectively increase the activity of the website and the frequency of search engine crawling.Below, I will elaborate on how to loop and display the latest 10 article lists in the AnQiCMS template.

2025-11-06

How to filter and display the article list according to a specified category ID?

As an experienced CMS website operation person, I know the importance of content organization and display for user experience and SEO.In daily work, we often need to filter and display article lists according to specific categories so that readers can quickly find the content they are interested in.Today, I will elaborate on how to flexibly and efficiently filter and display article lists in AnQiCMS according to specified category IDs.The categorization of content is the foundation for the effective operation of a website.

2025-11-06

How to implement pagination for the article list display function?

As a website operator who is deeply familiar with the operation of AnQiCMS, I understand that it is crucial to organize and present a large number of articles efficiently in content display.The pagination feature not only greatly enhances the user's browsing experience, but also avoids the visual fatigue caused by too much content on a single page, and is an indispensable part of the SEO strategy.To implement pagination display of article lists in AnQiCMS, it benefits from its flexible template engine and dedicated tag system, making the whole process clear and efficient.

2025-11-06

How to obtain the global system configuration information such as website name, Logo, etc?

As a website operator proficient in AnQi CMS content management, publishing, and optimization, I fully understand the importance of obtaining global website configuration information for website construction and daily maintenance.This information constitutes the basic framework of the website, including brand identification, contact information, SEO metadata, etc., ensuring the uniformity, professionalism, and maintainability of the website.In Anqi CMS, obtaining these global system configuration information is intuitive and flexible, mainly achieved through built-in template tags.

2025-11-06