As an experienced CMS website operation person, I am well aware of the importance of high-quality, well-structured content for website user experience and search engine optimization.The single page is the core of website basic information display, such as 'About Us', 'Contact Information', and 'Terms of Service' and so on.In AnQiCMS, through the powerful template tag system, we can flexibly obtain and display the content of these single pages.
I will elaborate in detail on how to obtain the list of all single pages and the detailed content of a specific single page in the AnQiCMS template.
Obtain the list of all single pages
In AnQiCMS template, to display the website's list of all single pages, we can usepageListThe tag can help us easily traverse and output all the single pages created, which is very useful when making a sitemap, footer navigation, or specific information module.
pageListThe label usage is concise and clear, it does not require additional parameters, and it will default to retrieving all single-page data under the current site. You can define the data retrieved to a variable and then throughforLoop through this variable, output the details of each single page one by one. For example, you can define the data aspages:
<ul>
{% pageList pages %}
{% for item in pages %}
<li>
<a href="{{item.Link}}">{{item.Title}}</a>
<p>{{item.Description}}</p>
{% if item.Thumb %}
<img src="{{item.Thumb}}" alt="{{item.Title}}" />
{% endif %}
</li>
{% endfor %}
{% endpageList %}
</ul>
In the above code,itemThe variable represents each single page object in the loop, you can access itsId(Page ID),Title(Page Title),Link(Page Link),Description(Page Description),Content(Page Content),Logo(Single page thumbnail large image) andThumb(Single page thumbnail) etc fields.
If you need to exclude certain pages based on specific conditions, althoughpageListThe tag itself does not have direct filtering parameters, but you canforcombine within the loopifLogical judgment for filtering. For example, to exclude a single page with ID 1:
<ul>
{% pageList pages %}
{% for item in pages %}
{% if item.Id != 1 %}
<li>
<a href="{{item.Link}}">{{item.Title}}</a>
<p>{{item.Description}}</p>
</li>
{% endif %}
{% endfor %}
{% endpageList %}
</ul>
In this way, you can flexibly control which single-page applications need to be displayed in the list. If your website is a multi-site architecture and you want to get a list of single-page applications under a specific site, you canpageListthe tag withsiteIdto specify the site ID.
Retrieve detailed content of a specific single page
When you need to display the complete content of a specific single page, such as the detailed introduction of the "About Us" page,pageDetailThe tag is your **choice. This tag allows you to accurately retrieve all field information for a single page based on the page ID or URL alias.
pageDetailThe basic usage of tags is, you can specify the field name you want to retrieve, or you can get the entire single page object into a variable. For example, to retrieve the title of the current visited single page:
<h1>{% pageDetail with name="Title" %}</h1>
To retrieve the content of a single page with ID 1:
<div>
{% pageDetail pageContent with name="Content" id="1" %}
{{pageContent|safe}}
</div>
It is worth noting that,Contentfields usually need to be accompanied by|safeA filter to ensure that HTML content is not escaped. Additionally, if the Markdown editor is enabled on the backend,ContentThe field will automatically convert Markdown to HTML. If you need to manually control the conversion behavior, you can userenderparameters, for examplerender=trueforce conversion,render=falsedisable conversion.
pageDetailThe supported parameters of the tag include:
id: The ID of the single page, used to specify the page to be retrieved accurately. If not provided, the single page information of the current page will be retrieved by default.token: Single page URL alias, can also be used to specify the page to be retrieved.siteId: withpageListSimilar, used to specify the site ID in a multi-site environment.
BypageDetail, fields you can access include:Id(Page ID),Title(Page Title),Link(Page Link),Description(Page Description),Content(Page Content),Logo(Full-page thumbnail large image),Thumb(Full-page thumbnail) as well asImages(Full-page slide set).
When you need to display multiple images on a single page (such as Banner images or slides),ImagesThe field will return an array. You can iterate through these images one by one:
{% pageDetail pageImages with name="Images" %}
<ul>
{% for item in pageImages %}
<li>
<img src="{{item}}" alt="{% pageDetail with name="Title" %}" />
</li>
{% endfor %}
</ul>
In AnQiCMS, the template file for a single page is usually agreed upon aspage/detail.html. If you wish to use a separate template for a specific single page (such as a page with ID 10), you can name itpage/detail-10.html. Further, you can specify a custom template name for a specific page in the single-page management background, for exampleabout.html, and then place the file in the template directory underpage/about.html.
BypageListandpageDetailThese powerful tags, as a website operator, you can easily handle the single-page content display of AnQiCMS, meeting various complex website layout and information presentation needs.
Frequently Asked Questions (FAQ)
How do I add a single page to the website navigation?
You can create or edit navigation links in the 'Website Navigation Settings' feature of the AnQiCMS backend.In the 'Link Type' select 'Category Page Link', then select the single page you want to add.This single page will display at the navigation location you specified.
Can I set a unique template for a specific 'About Us' page?
Yes, AnQiCMS supports the use of custom templates on single pages. You can create your custom HTML template files in the directory under the template.page/folder, for example,about.html. Then, edit the "About Us" page in the AnQiCMS background "Page Management", and fill in the "Single Page Template" fieldabout.htmlJust do it.
How should the SEO of a single page be optimized?
Each single page has an independent SEO setting area in the 'Page Management' section of the AnQiCMS backend.You can set 'SEO title', 'keywords', and 'single page description' (corresponding to Description) for each single page.These fields will be directly output to the page<title>and<meta>It is crucial in tags for search engine optimization. At the same time, it is recommended to ensure that the URL alias (custom URL) of a single page is descriptive and contains keywords to enhance SEO effects.