AnQiCMS (AnQiCMS) is an enterprise-level content management system that focuses on efficiency, security, and SEO-friendliness. In the design of template tags, it fully embodies these concepts. Focusing on the issue ofarchiveFiltersThe label is dynamically generated as a filtering condition or statically pre-generated? This topic, we can delve into the unique features of AnQiCMS in handling such functions.
archiveFiltersThe mechanism of the tag: server-side pre-generated
To understandarchiveFiltersHow a tag works, first you need to clarify the underlying architecture of AnQiCMS.AnQiCMS is developed in Go language and uses a template engine syntax similar to Django.Server-sideThe HTML content has been rendered. The server will only send the generated HTML content to the user's browser once it is completely generated.
archiveFiltersThe label is a typical example of this server-side rendering process. From its usage{% archiveFilters filters with moduleId="1" allText="全部" %}...{% endarchiveFilters %}It can be seen that this is a standardTemplate Tag. At the template parsing stage of AnQiCMS, when the server processes toarchiveFilterstags, it will perform the following operations:
- For example, according to the parameters specified by the tag,
moduleId(Model ID) and the context of the current page (such as category ID, URL query parameters, etc.), query all related document model custom fields and their optional values from the database. - Build a data structure that includes all filtering conditions, this structure will include the name of each filtering parameter, the field name, and all optional values under it. For each optional value, the system will also generate the correspondingFilter link(usually a URL with different query parameters), and mark the currently selected option (
IsCurrent) - Name this complete data structure (in the example named
filtersFill into the template and utilizeforLoop and other template syntax, directly embed these filtering conditions (including text labels, links, and selected status) intothe final generated HTML code.
This means that when the user's browser receives the page, all the filtering conditions - including the 'All' option, specific parameter values, and the corresponding clickable links - are fully present in the page's HTML source code.They are not generated by JavaScript code that is asynchronously requested after the page is loaded.
Why choose server-side pre-generation?
AnQiCMS chooses this server-side pre-generation method not by chance, as it is closely linked to the core advantages and design philosophy of the system:
- Ultimate SEO friendliness
- Page load speed and user experience: Since all the filtering conditions are in the initial HTML, the browser can obtain the complete page structure and content on the first request, without waiting for additional JavaScript execution or data requests.This helps to speed up the first screen rendering, providing users with a smoother, seamless browsing experience.
- Manifestation of high-performance architectureBased on Go language, AnQiCMS is good at high concurrency and fast processing.Placing the generation of filtering conditions on the server side can fully utilize the high-performance advantages of the Go language, completing complex database queries and template rendering in a short time, thereby efficiently transmitting the complete HTML content to the client.
- Simplified and efficient template developmentFor template developers, using tags and loops directly in the template to output filtering conditions avoids writing complex client-side JavaScript code to handle data retrieval and DOM operations, making the template structure clearer and improving development efficiency.
Manifestation in actual operation
In actual use, when a user clicks on a button on the AnQiCMS websitearchiveFiltersThe following situations usually occur when filtering conditions generated by tags are applied:
- The page will initiate a new HTTP request, the URL will include new filter parameters (such as
?category_id=X¶m_name=Y) - The server receives this new request and will query the database according to the parameters in the URL, re-render the page, generate a content list that meets the filtering conditions, and also update
archiveFiltersThe corresponding option in the labelIsCurrentStatus, send the complete HTML page to the browser again.
Although modern front-end technology can also be realized through AJAX and other means for partial refresh, but it is the AnQiCMSarchiveFilterstags used to generate filtering conditionsstructure and initial contentIt still adheres to the server-side pre-generated strategy to ensure its SEO and performance advantages.
Summary
In summary, AnQiCMS'archiveFiltersis a tagstatic pre-generation
Frequently Asked Questions (FAQ)
Q:
archiveFiltersLabel pre-generated filtering conditions, whether it supports interaction through JavaScript, for example, to implement a click without jumping and only refresh the content locally?A:archiveFiltersThe tag itself generates HTML structure and links.Although its core is pre-generated on the server side, developers can completely use front-end JavaScript code (such as jQuery or Vue frameworks) after the page is loaded to intercept the click events of these filter links, and achieve local content refresh through AJAX technology, thereby avoiding a full page reload.But this belongs to the category of secondary development, AnQiCMS provides a complete page jump solution by default.Q: What are the specific benefits of this server-side pre-generated filtering method for my website's SEO?A: The main benefits lie inScalability and indexability.The search engine crawler can directly find and understand the structure of all filtering conditions and the URL they point to when accessing your page.This means that, whether it is the filter conditions themselves or the content pages filtered out through these conditions, there is a higher chance that they will be discovered, indexed, and included by search engines, thereby enhancing the search visibility of these pages.Content generated dynamically is often difficult to index effectively.
Q: Can I customize?
archiveFiltersThe appearance and style of the filter conditions generated by the label?A: Of course you can.archiveFiltersThe HTML content of the tag can be fully controlled by CSS styles.By defining the corresponding selector rules in the CSS file, you can freely adjust the visual properties such as font, color, background, layout, and so on of the filtering conditions.forLoop, you can also adjust the HTML structure at the template level to meet different design requirements.