As a website operator who deeply understands the operation of AnQiCMS, I fully understand your concerns about website performance, security, and external dependency control.The AnQi CMS is known for its lightweight and efficient Go language, providing strong support in content management, which naturally includes good handling of Markdown content.Now, let's discuss in detail how to achieve the localization deployment of Markdown plugins for a security CMS without using a CDN, thereby avoiding external dependencies.
English CMS Markdown function and the essence of external dependencies
The AutoCMS indeed built-in Markdown editor, which greatly facilitates content creators.However, when it comes to more advanced Markdown rendering, such as mathematical formulas (based on LaTeX or MathML) and flowcharts (such as Mermaid), their correct display on the browser side often requires additional JavaScript libraries and CSS style sheets for parsing and rendering.github-markdown-cssjsDelivr'sMathJaxandMermaid)to introduce these auxiliary functions, this is mainly due to the convenience of deployment and the efficiency of global distribution.
Here it is clear that these 'plugins' do not refer to the Go language plugins on the server side of the Anqi CMS backend, but rather to the front-end static resources (CSS and JavaScript libraries) that run in the user's browser.The autoCMS as a backend system is responsible for processing Markdown text and sending it to the browser, while the browser needs these frontend libraries to render Markdown text into rich visual effects.Therefore, whether it can be localized and deployed depends on whether these front-end static resources can be hosted locally by the CMS server and provided to the browser.
The practice of localizing Markdown-related front-end resources
The answer is affirmative, the Anqi CMS fully supports the localization deployment of these Markdown-related front-end resources to avoid external dependence on CDN.This is because the design of AnQi CMS allows you to host and provide static files on the server.
The template creation agreement of AnQi CMS explicitly points out that the "styles, js scripts, images, and other static resources required by the template are stored separately in/public/static/Catalog. This means that as long as you reference the CDN on the.cssand.jsThe file is downloaded, placed in this static resource directory, and the reference path in the template file is modified. The browser can then load these resources locally from your security CMS server.
The specific operation steps are as follows:
1. Localize Markdown default style (for examplegithub-markdown-css)
You can directly access the CSS file link provided by CDN (for examplehttps://cdnjs.cloudflare.com/ajax/libs/github-markdown-css/5.2.0/github-markdown.min.css),Save the file content to local and name itgithub-markdown.min.css. Then, upload this file to your CMS installation directory under/public/static/css/path (ifcssFolder does not exist, you can create it manually).
Next, you need to edit the security CMS'sbase.htmltemplate file. Find the original reference CDN.<link>Label, change it to reference a local path, for example:
<link rel="stylesheet" href="/static/css/github-markdown.min.css" crossorigin="anonymous" />
Please note,crossorigin="anonymous"andreferrerpolicy="no-referrer"Attributes are typically used for CORS and privacy control. When deploying locally, if the files are hosted on the same origin, these attributes can be omitted or adjusted according to your specific security policy.
2. Localized math formula rendering library (e.g.,)MathJax)
Access the CDN link of MathJax (e.g.,)https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js), download its JavaScript file, and save it astex-mml-chtml.js。Upload this file to/public/static/js/mathjax/directory (make surejsandmathjaxthe folder exists).
Then, inbase.htmltemplate, reference MathJax's<script>标签修改为:English
<script id="MathJax-script" async src="/static/js/mathjax/tex-mml-chtml.js"></script>
3. 本地化流程图渲染库(例如Mermaid)
同样,下载Mermaid的JavaScript模块文件(例如https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs),保存为Englishmermaid.esm.min.mjsEnglish/public/static/js/mermaid/directory.
EnglishimportThe statement is directly loaded from CDN. After localization, the reference method in the template also needs to be adjusted accordingly:
<script type="module">
import mermaid from '/static/js/mermaid/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
Balance and consideration
Advantages:
The main advantage of localizing the deployment of Markdown-related plugins is to have full control over the availability, version, and security of these front-end resources.You no longer rely on the stability and speed of third-party CDN services, reducing the risk of website functionality being damaged due to CDN failure or policy adjustments.In addition, for certain user groups or internal network environments, loading resources from local servers may be faster than from distant CDN nodes, thus improving user experience.
Disadvantages:
Of course, localization deployment also comes with some trade-offs.The most significant point is the increase in maintenance costs.When these frontend libraries release new versions, you need to manually download, replace the local files, and test compatibility.This loses the convenience of CDN automatic update and version management.At the same time, CDNs typically have global nodes and can provide proximity services based on the user's geographic location, and make use of the browser caching mechanism to reduce redundant downloads.For global users, localized deployment may sacrifice some edge acceleration and caching efficiency.
Conclusion
In summary, the Anqi CMS fully supports the localization deployment of Markdown-related frontend plugins, which can be achieved through simple file download and template path modification.As a website operator, you need to decide whether to adopt the convenience of CDN or choose full control brought by local deployment based on your actual user group, performance requirements, security strategy, and operational resources.In many cases, especially for users focused on specific regions or enterprises with strict security requirements, on-premises deployment is a worthwhile choice.
Common Questions and Answers (FAQ)
Q1: After localizing the deployment of these Markdown-related plugins, will it affect the backend performance of the security CMS?
A1: No. Markdown related plugins (such asgithub-markdown-css/MathJax/Mermaid)is purely frontend static resources (CSS and JavaScript).The backend of Anqi CMS uses Go language, responsible for generating HTML content and providing these static files.Once the browser has loaded the page and these localized static files, all Markdown rendering is done on the user's browser side, and it does not impose any additional burden on the backend performance of the Safe CMS.
Q2: If I choose local deployment and these front-end plugins have new versions, how should I update them?
A2: You need to manually follow the official release channels of these front-end plugins or their CDN provider's version update information. Once a new version is released, you need to manually download the latest.cssand.jsFiles, replace the old files/public/static/in the corresponding directory under your server and make surebase.htmlThe reference path in the template is still correct. After updating, it is recommended to clear the browser cache and perform a comprehensive test to ensure that the function works normally and no new compatibility issues have been introduced.
Q3: After local deployment, will you lose the caching advantage brought by CDN?
A3: Yes, part of the global caching advantage brought by CDN will be lost.CDN through its globally distributed node network, allows users to obtain resources from the server closest to them, and uses HTTP cache headers to implement multi-level caching between the user's browser and the CDN node.Localized deployment will cause all requests to return directly to your source server.Although the browser will still cache according to your server's HTTP cache configuration, without the geographical distribution and global shared cache capabilities of the CDN, the initial loading speed may be slightly affected for users scattered geographically.However, for domestic users or users in specific regions, if the server bandwidth is sufficient, the local loading speed may actually be faster.