As an experienced website manager familiar with AnQiCMS operation, I understand the importance of content quality and user experience in attracting and retaining readers.When your carefully prepared Mermaid flowchart fails to display normally on the AnQiCMS page, it will undoubtedly affect the expressiveness of the content.In AnQiCMS, the rendering of Mermaid flowcharts involves several key steps, we need to check each one in turn to ensure all configurations are correct and accurate.
The most common and core reason is often due to the JavaScript library required for Mermaid rendering not being properly introduced into your website's front-end template.Mermaid itself is a text-based chart description language that requires a frontend JavaScript library to parse these text descriptions and render them into visual SVG graphics.According to our document instructions, especially in the section This means you need to be in the main template file of the website, usuallybase.htmlof<head>Part, add a specific Mermaid JavaScript reference.If this code is missing, or if the path to this code is incorrect or fails to load, then your Mermaid diagram will not be recognized and drawn by the browser.
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@10/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: true });
</script>
Another important reason is the settings of the content editor.AnQi CMS supports Markdown editor, and Mermaid flowcharts are usually written in inline code blocks within Markdown content.If your document is being edited in the background and the Markdown editor is not enabled, the system may not recognize the Mermaid text code as a diagram but will output it as plain text.You need to go to the AnQiCMS background "Global Settings" -> "Content Settings" to confirm that the Markdown editor option is checked and saved.Only when the Markdown editor is enabled, the system will parse and convert the Markdown syntax in the content (including Mermaid code blocks).
Moreover, syntax errors in the Mermaid code itself may also cause the diagram to not display.Even if you correctly introduce the JavaScript library and enable the Markdown editor, if there are syntax errors inside the Mermaid code block, such as missing necessary symbols, incorrect connectors, or incomplete structure, then the Mermaid library will fail when trying to parse it.In this case, the browser console (usually opened by pressing F12) may display JavaScript errors.It is recommended that you use an online Mermaid editor (such as Mermaid Live Editor) to validate your Mermaid code before rendering, to exclude any issues with the code itself.
The website cache may also be an interference factor. After changing the configuration or template files of AnQiCMS, especially when modifyingbase.htmlAfter such a core template file, old cache data may cause the front-end page to not update in time.At this time, you need to go to the AnQiCMS backend, find the "Update Cache" feature, manually clear the website cache, and it is recommended to clear the local cache of your browser, then re-access the page to see the effect.
Finally, potential conflicts with browser environments and other scripts on the page may occasionally affect the rendering of Mermaid.Some browser extensions or other JavaScript libraries loaded on the page may inadvertently interfere with the normal operation of the Mermaid library.Although this situation is relatively rare, if the aforementioned methods fail to solve the problem, you can try testing in different browsers or temporarily disabling some browser extensions to troubleshoot.Check the browser console for network requests, ensure that Mermaid's CDN resources are loaded successfully and are not blocked or failed due to network issues.
In summary, the main reason why Mermaid flowcharts do not display on the AnQiCMS page is usually centered around the loading and content parsing of the Mermaid JavaScript library.Systematically check these links, it usually helps you quickly locate and solve problems.
Frequently Asked Questions
1. Where can I find and editbase.htmlHow to add Mermaid script to the file?
You can find the template management in the "Template Design" area of the AnQiCMS backend. Under the currently enabled template directory, there is usually a folder namedbase.html(or a similar general layout file) file. You can directly modify it through the background online editing function and paste the Mermaid JavaScript script into<head>The label inside. Please note that modifying the template file directly should be done with caution, it is recommended to back up the relevant files before making changes.
How to confirm that the AnQiCMS Markdown editor is enabled?
To enable the Markdown editor, you need to log in to the AnQiCMS backend, navigate to the "Content Settings" page under "Backend Settings".In this page, find the options related to Markdown editor and ensure it is checked or enabled.After saving the settings, the system will provide Markdown parsing support while you are editing the document content.
3. My Mermaid code works normally in the online editor, but it still does not display on the AnQiCMS page, what should I do?
If the Mermaid code itself is not problematic, the issue may be with the loading or execution of the Mermaid JavaScript library. First, please check again.base.htmlIs the path of the Mermaid script included correctly, ensure there are no spelling mistakes.Next, open the browser's developer tools (usually press F12), switch to the "Console" (console) and "Network" (network) panels.mermaid.esm.min.mjsWhether the load is successful (status code 200), whether it is intercepted or failed to load.If loading fails, it may be due to network issues or firewall blocking.Finally, try to clear the AnQiCMS system cache and your browser cache.