As a website operator who deeply understands the operation of AnQiCMS, I fully understand your concerns about website performance, security, and control over external dependencies.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 whether the Anqicms CMS can achieve the localization deployment of Markdown-related plugins without using CDN, thus avoiding external dependencies.
The essence of AnQiCMS Markdown feature and external dependencies
AnQi CMS indeed comes with a 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.The official documentation recommends using CDN resources (such as Cloudflare'sgithub-markdown-cssof jsDelivr,MathJaxandMermaidTo introduce these auxiliary functions, it is mainly for the convenience of deployment and the efficiency of global distribution.
It should be clearly stated that these 'plugins' do not refer to the server-side Go language plugins of Anqicms CMS backend, but rather to the front-end static resources (CSS and JavaScript libraries) that run on the user's browser side.The Anqi CMS acts as a backend system, responsible for processing Markdown text and sending it to the browser, while the browser needs these frontend libraries to render the Markdown text into rich visual effects.Therefore, whether it can be locally deployed depends on whether these front-end static resources can be hosted locally by the Anqi CMS server and provided to the browser.
The practice of localizing the deployment of Markdown-related front-end resources.
The answer is affirmative, Anqi CMS fully supports the localization deployment of these Markdown-related frontend resources to avoid external dependency on CDN.This is because the design of AnQi CMS allows you to host and provide static files on the server.
The Anqi CMS template production agreement clearly states that the static resources required by the template, such as styles, js scripts, images, etc., are stored separately./public/static/The catalog. This means that as long as you refer to the CDN hosted.cssand.jsThe file is downloaded, placed in this static resource directory, and the reference path in the template file is modified, then the browser can locally load these resources from your safe CMS server.
The specific steps are as follows:
1. Localized 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 locally and name itgithub-markdown.min.css。Then, upload this file to the directory of your AnQi CMS installation/public/static/css/path ifcssThe folder does not exist, you can create it manually).
Next, you need to edit the Anqi CMS).base.htmlTemplate file. Find the original reference CDN).<link>Label, change it to refer to the local path, for example:
<link rel="stylesheet" href="/static/css/github-markdown.min.css" crossorigin="anonymous" />
Please note,crossorigin="anonymous"andreferrerpolicy="no-referrer"Properties are typically used for CORS and privacy control. When deploying locally, if the files are hosted on the same origin, these properties can be omitted or adjusted according to your specific security policy.
2. A localized mathematical formula rendering library (for exampleMathJax)
Access the CDN link of MathJax (for examplehttps://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 sure thatjsandmathjaxthe folder exists).
Then, inbase.htmlIn the template, reference the MathJax's<script>tag to be changed to:
<script id="MathJax-script" async src="/static/js/mathjax/tex-mml-chtml.js"></script>
3. Localized flowchart rendering library (for exampleMermaid)
Similarly, download the Mermaid JavaScript module file (for examplehttps://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs), and save it asmermaid.esm.min.mjs, and upload it to/public/static/js/mermaid/Directory.
For Mermaid, since it is an ES module, the original document usesimportThe statement is directly loaded from CDN. After localization, the way of reference in the template also needs to be adjusted:
<script type="module">
import mermaid from '/static/js/mermaid/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
Weigh and consider
Advantage:
The main advantage of localizing Markdown-related plug-ins is the full control over the availability, version, and security of these frontend 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 failures or policy adjustments.In addition, for certain user groups or internal network environments, loading resources from a local server may be faster than from a distant CDN node, thereby enhancing user experience.
Shortcomings:
Of course, localized 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 updates and version management.At the same time, CDNs typically have global nodes, which can provide proximity services based on the user's geographical location and utilize browser caching mechanisms to reduce redundant downloads.For global users, localized deployment may sacrifice some edge acceleration and caching efficiency.
Conclusion
In summary, Anqi CMS fully supports the localization deployment of Markdown-related frontend plugins, which can be realized through simple file downloads and template path modifications.As a website operator, you need to decide based on your website's actual user group, performance requirements, security policies, and operational resources, whether to adopt the convenience of CDN or choose the complete control brought by localized deployment.In many cases, especially for enterprises focusing on specific regional users or with strict security requirements, localized deployment is a worthwhile choice.
Frequently Asked Questions (FAQ)
Q1: After localizing the deployment of these Markdown-related plugins, will it affect the backend performance of Anqi CMS?
A1: I don't know. Markdown-related plugins such asgithub-markdown-css/MathJax/Mermaid)is a pure front-end static resource (CSS and JavaScript).The Anqi CMS backend is written in Go, responsible for generating HTML content and providing these static files.Once the browser loads 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 Anqi CMS.
Q2: If I choose to deploy locally, 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 frontend plugins or the version update information of their CDN providers. Once a new version is released, you need to manually download the latest one..cssand.jsfile, replace it on your server/public/static/and make sure the corresponding old file in the directory is replacedbase.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, some of the global caching advantages 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 utilizes HTTP cache headers for multi-level caching between the user's browser and the CDN nodes.After localization deployment, all requests will be directly returned to your source server.Although the browser will still cache according to your server's HTTP cache configuration, it has lost the geographic distribution and global shared cache capabilities of the CDN, which may slightly affect the initial loading speed 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.