What is the correct method to call the push JS code using the `pluginJsCode` tag in the template?

Calendar 👁️ 68

As an experienced AnQiCMS website operator, I know that it is crucial to integrate third-party services efficiently and correctly in the process of content management and website optimization.Especially for the JavaScript push code of search engines, AnQiCMS provides a special and convenient solution.

Integrate JS push code in AnQiCMS template

In modern website operation, maintaining good interaction with search engines is the key to improving content inclusion and exposure rate.Although Baidu and Bing and other mainstream search engines provide API interfaces for active link push, some platforms such as 360 Search and Toutiao Search mainly achieve automatic submission by embedding JavaScript code in the website page.To manage these scripts uniformly, AnQiCMS providespluginJsCodeTags that make it easy for website operators to integrate these push scripts into website templates without having to directly modify the template files.

The advantage of this mechanism lies in the fact that all third-party JS push codes can be configured and managed uniformly in the AnQiCMS backend.When you need to update, add, or remove the JS code for a platform, just perform the operation in the background, and the system will automatically render it to the specified template location.This greatly reduces maintenance costs, reduces errors introduced by manual template modification, and also ensures that the code takes effect in a timely manner.

Configure the background operation of the JS push code

Use correctlypluginJsCodeLabel, first you need to configure it in the AnQiCMS admin interface.You can go to the "Function Management" under the "Link Push" module.In this module, you will find a section named "360/Toutiao and JS Auto Submission".

Here, you need to paste the complete JavaScript push code obtained from the corresponding search engine platform into the specified input box. Please note that when pasting, you must include<script>The start and end tags, for example:<script>...</script>. AnQiCMS will be responsible for storing it as a whole and subsequent template rendering.This centralized management approach separates the front-end and back-end logic of the website, which helps keep the website code neat and secure.

Call in the templatepluginJsCodeTag

It is very intuitive to call these pre-configured JS push codes in the AnQiCMS template. You just need to insert them at the location where you need to display the codepluginJsCodeTags can be placed. Usually, these push scripts are placed in the HTML page<head>tags or</body>before the closing tag to ensure that they can be executed in time when the page is loaded.

The specific template calling method is:

{{- pluginJsCode|safe }}

Among them,pluginJsCodeIs the placeholder for the JS code content you configure in the background.|safeThe filter plays a crucial role here. The AnQiCMS template engine defaults to escaping output content to prevent cross-site scripting attacks (XSS).However, for JavaScript code, we do not want it to be escaped, but rather to be parsed and executed as pure script by the browser.|safeThe filter is used to inform the template engine that the content output here is safe and does not require escaping.

Furthermore,{-Prefix, that is,{{-It is a syntax used to control the removal of leading whitespace when the template is output.In some cases, it helps to keep the generated HTML code neat, avoiding unnecessary blank lines or spaces.

By following these steps, AnQiCMS can ensure that the third-party JS push code is correctly loaded and executed on your website, thereby effectively improving the search engine's crawling and indexing efficiency for its content, providing strong support for your website's SEO optimization.


Frequently Asked Questions (FAQ)

Ask: Why do you need to call in the templatepluginJsCodewhen using|safeFilter?

Answer:|safeThe filter is required because the AnQiCMS template engine, for security reasons, defaults to escaping all output HTML content to prevent cross-site scripting attacks (XSS). If you do not use|safeYour JavaScript code will not be executed by the browser as executable script, but will be displayed as plain text on the page, resulting in the failure of the push function.|safeTell the template engine that this section of content is safe and does not need to be escaped.

What could be the reason if I paste the JS code into the background and the front-end page does not display or the function does not work?

Answer: There may be several reasons. First, please check whether you have pasted the complete JavaScript code correctly in the "Link Push" section of the background "360/Toutiao and other JS automatic submission" part, including<script>and</script>Label. Next, confirm that you have used the correct call label in the template{{- pluginJsCode|safe }}. Also, if you are using a CDN or cache, please try to clear the website cache and CDN cache, and refresh the browser (Ctrl+F5) to ensure that the latest page is loaded.

Question:pluginJsCodeCan the tag insert JS code into any position on the page? For example, only into the header of a specific article page?

Answer:pluginJsCodeThe tag is a system-wide JavaScript code insertion method, which will insert the configured JavaScript code into all pages that call the tag. If you need to insert JavaScript code on a specific page or under specific conditions, you usually need to use more advanced template logic judgment (such as{% if %}statement), or to implement other finer-grained custom JS injection functions provided by AnQiCMS, rather than just relying onpluginJsCode.pluginJsCodeUsed for those JavaScript scripts that need to exist globally, such as site-wide statistics or push codes.

Related articles

What should be noted in link push for multilingual websites?

As an experienced website content expert in AnQiCMS (AnQiCMS) operation, I fully understand the importance of multilingual website content management and promotion in the wave of internationalization.Especially in the link push phase, multilingual websites face more complex and detailed challenges compared to single-language websites.AnQi CMS with its strong multilingual support and SEO tools provides a solid foundation for us to effectively meet these challenges.

2025-11-06

How does AnQiCMS's scheduled publishing function work in conjunction with link push?

As an experienced website operator, I am well aware of the importance of content timeliness and search engine inclusion speed for website traffic and user attraction.In the powerful feature matrix of AnQiCMS, the functions of scheduled publishing and link push, if they can operate in a clever way, will greatly enhance our content operation efficiency and SEO performance.Next, I will elaborate on how these two functions of AnQiCMS achieve efficient collaboration.### Schedule publishing feature: The automated tool to control the rhythm of content In the daily work of content operation, we often need to

2025-11-06

What are the requirements for the static URL structure of the link push function?

As a website content expert who deeply understands the operation of AnQiCMS (AnQiCMS), I know that content is the cornerstone of the website, and how to make these contents discovered by more people is the key to successful operation.The link push feature provided by AnQi CMS is undoubtedly a powerful tool to accelerate content exposure, but to fully utilize its effectiveness, the URL structure of the website, especially the pseudo-static URL, plays a crucial role.

2025-11-06

Will AnQiCMS support active push to more search engines in the future, besides Baidu and Bing?

As an experienced CMS website operation personnel in the security industry, I fully understand the value of content creation and the importance of search engine optimization.We are committed to helping users enhance content exposure and website traffic through AnQiCMS, among which, the active push function of search engines is a key link to achieve this goal.For "Besides Baidu and Bing, will AnQiCMS support the active push of more search engines in the future?This question, I can elaborate in detail from the current capabilities of our system, the industry status, and the extensibility advantages of AnQiCMS

2025-11-06

Does link push support selective push of documents for specific categories or models?

As an expert in the operation of AnQiCMS, I fully understand your need for refined control over the link push function.In daily content operations, we often hope to intelligently push content to search engines to maximize their inclusion effect and improve SEO performance.In response to the question you raised about whether the link push supports selective push of documents for specific categories or models, I will elaborate in detail on the existing documents of Anqi CMS.

2025-11-06

What is the complementary role of AnQiCMS' advanced SEO tools (such as Sitemap) and link push?

AnQiCMS (AnQiCMS) is an efficient content management system that is committed to enhancing the search engine performance of websites through a series of built-in features.Among them, the Sitemap generation function in the advanced SEO tool and the link push mechanism together constitute an important pillar for the good visibility of the website in search engines.As an experienced website operator, I know that these two functions are not independent of each other, but complementary, working together to optimize the crawling and indexing effect of the website in search engines.

2025-11-06

How can you perform an effective test after configuring the link push function to ensure it works properly?

As an experienced senior who has been deeply involved in the CMS content operation of an enterprise for many years, I know the importance of the link push function for website SEO.It is like a 'fast lane' for content, which can help our high-quality content be discovered and indexed by search engines more quickly.After you configure the link push function in the Anqi CMS backend, an effective test is to ensure that it operates normally and avoids 'black box operations'.Here are the detailed steps for you to perform a comprehensive test to verify that the link push function is working normally.### Make sure the configuration is correct: The primary step before testing Before starting the specific test process

2025-11-06

Why hasn't the inclusion speed of my website increased significantly after configuring the link push?

As a professional who deeply understands the operation of AnQiCMS and website operation strategies, I understand that you are still confused about the lack of significant improvement in the speed of inclusion after configuring link push.Of course, link promotion is an important means to improve the efficiency of search engine crawling, but it is not an omnipotent 'accelerator'.The speed of inclusion is affected by a variety of factors, and link promotion is just one of them.Next, I will analyze the possible reasons from the functional advantages of AnQiCMS and provide corresponding optimization suggestions.

2025-11-06