[{"content":"Stack theme has a built-in support for image galleries. It allows you to create a beautiful gallery by simply placing multiple images side-by-side.\nSample Gallery How it works The gallery is powered by Photoswipe and a custom internal script. It automatically calculates the best layout for your images based on their aspect ratios.\nTo create a gallery, you just need to put multiple images in the same line (or paragraph).\nSyntax ![Image 1](image1.jpg) ![Image 2](image2.jpg) ![Image 3](image3.jpg) ![Image 4](image4.jpg) Note: There should be two spaces between the images to ensure they stay in the same line in Markdown\nGallery Syntax inspired by Typlog\n","date":"2026-01-26T00:00:00Z","image":"/p/image-gallery/helena-hertz-wWZzXlDpMog-unsplash_hu_a848fc6c0b02c727.webp","permalink":"/p/image-gallery/","title":"Image Gallery"},{"content":"Stack theme also provides some custom shortcodes to enhance your content.\nQuote The quote shortcode allows you to display a quote with an author, source, and URL.\nLorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\n― A famous person, The book they wrote Usage {{\u003c quote author=\"Author Name\" source=\"Source Title\" url=\"https://example.com\" \u003e}} Quote content here. {{\u003c /quote \u003e}}Video The video shortcode allows you to embed self-hosted or remote video files.\nYour browser doesn't support HTML5 video. Here is a link to the video instead. Usage {{\u003c video src=\"https://example.com/video.mp4\" \u003e}}Bilibili Embed videos from Bilibili. Supports both av and bv IDs.\nUsage {{\u003c bilibili \"BV1634y1t7xR\" \u003e}}YouTube Hugo\u0026rsquo;s built-in YouTube shortcode.\nUsage {{\u003c youtube ZJthWmvUzzc \u003e}}Tencent Video Embed videos from Tencent Video.\nUsage {{\u003c tencent \"u00306ng962\" \u003e}}GitLab Snippet Embed snippets from GitLab.\nUsage {{\u003c gitlab 2349278 \u003e}}Diagrams Stack supports Mermaid diagrams out of the box.\ngraph TD; A--\u003eB; A--\u003eC; B--\u003eD; C--\u003eD;Usage Wrap your Mermaid code in a code block with the language set to mermaid.\n```mermaid graph TD; A--\u003eB; A--\u003eC; B--\u003eD; C--\u003eD; ```","date":"2026-01-26T00:00:00Z","permalink":"/p/shortcodes/","title":"Shortcodes"},{"content":"This article offers a sample of basic Markdown syntax that can be used in Hugo content files, also it shows whether basic HTML elements are decorated with CSS in a Hugo theme.\nHeadings The following HTML \u0026lt;h1\u0026gt;—\u0026lt;h6\u0026gt; elements represent six levels of section headings. \u0026lt;h1\u0026gt; is the highest section level while \u0026lt;h6\u0026gt; is the lowest.\nH3 H4 H5 H6 Paragraph Xerum, quo qui aut unt expliquam qui dolut labo. Aque venitatiusda cum, voluptionse latur sitiae dolessi aut parist aut dollo enim qui voluptate ma dolestendit peritin re plis aut quas inctum laceat est volestemque commosa as cus endigna tectur, offic to cor sequas etum rerum idem sintibus eiur? Quianimin porecus evelectur, cum que nis nust voloribus ratem aut omnimi, sitatur? Quiatem. Nam, omnis sum am facea corem alique molestrunt et eos evelece arcillit ut aut eos eos nus, sin conecerem erum fuga. Ri oditatquam, ad quibus unda veliamenimin cusam et facea ipsamus es exerum sitate dolores editium rerore eost, temped molorro ratiae volorro te reribus dolorer sperchicium faceata tiustia prat.\nItatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sapicia is sinveli squiatum, core et que aut hariosam ex eat.\nBlockquotes The blockquote element represents content that is quoted from another source, optionally with a citation which must be within a footer or cite element, and optionally with in-line changes such as annotations and abbreviations.\nBlockquote without attribution Tiam, ad mint andaepu dandae nostion secatur sequo quae. Note that you can use Markdown syntax within a blockquote.\nBlockquote with attribution Don\u0026rsquo;t communicate by sharing memory, share memory by communicating.\n— Rob Pike1\nBlockquote with alert 📝 Note Highlights information that users should take into account, even when skimming.\n📝 Custom title You can also provide a custom title for the note alert.\n💡 Tip Optional information to help a user be more successful.\n📌 Important Crucial information necessary for users to succeed.\n⚠️ Warning Critical content demanding immediate user attention due to potential risks.\n🚨 Caution Negative potential consequences of an action.\nTables Tables aren\u0026rsquo;t part of the core Markdown spec, but Hugo supports supports them out-of-the-box.\nName Age Bob 27 Alice 23 Inline Markdown within tables Italics Bold Code italics bold code A B C D E F Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus ultricies, sapien non euismod aliquam, dui ligula tincidunt odio, at accumsan nulla sapien eget ex. Proin eleifend dictum ipsum, non euismod ipsum pulvinar et. Vivamus sollicitudin, quam in pulvinar aliquam, metus elit pretium purus Proin sit amet velit nec enim imperdiet vehicula. Ut bibendum vestibulum quam, eu egestas turpis gravida nec Sed scelerisque nec turpis vel viverra. Vivamus vitae pretium sapien Code Blocks Code block with backticks \u003c!doctype html\u003e Example HTML5 Document Test\nCode block indented with four spaces \u0026lt;!doctype html\u0026gt; \u0026lt;html lang=\u0026quot;en\u0026quot;\u0026gt; \u0026lt;head\u0026gt; \u0026lt;meta charset=\u0026quot;utf-8\u0026quot;\u0026gt; \u0026lt;title\u0026gt;Example HTML5 Document\u0026lt;/title\u0026gt; \u0026lt;/head\u0026gt; \u0026lt;body\u0026gt; \u0026lt;p\u0026gt;Test\u0026lt;/p\u0026gt; \u0026lt;/body\u0026gt; \u0026lt;/html\u0026gt; Diff code block [dependencies.bevy] git = \"https://github.com/bevyengine/bevy\" rev = \"11f52b8c72fc3a568e8bb4a4cd1f3eb025ac2e13\" - features = [\"dynamic\"] + features = [\"jpeg\", \"dynamic\"]One line code block A paragraph\nList Types Ordered List First item Second item Third item Unordered List List item Another item And another item Nested list Fruit Apple Orange Banana Dairy Milk Cheese Other Elements — abbr, sub, sup, kbd, mark GIF is a bitmap image format.\nH2O\nXn + Yn = Zn\nPress CTRL + ALT + Delete to end the session.\nMost salamanders are nocturnal, and hunt for insects, worms, and other small creatures.\nThe above quote is excerpted from Rob Pike\u0026rsquo;s talk during Gopherfest, November 18, 2015.\u0026#160;\u0026#x21a9;\u0026#xfe0e;\n","date":"2026-01-25T00:00:00Z","image":"/p/markdown-syntax-guide/pawel-czerwinski-8uZPynIu-rQ-unsplash_hu_d3dd3a51085fa15e.webp","permalink":"/p/markdown-syntax-guide/","title":"Markdown Syntax Guide"},{"content":"The Stack theme supports rendering mathematical notation using KaTeX.\nEnabling KaTeX Per-page basis To enable KaTeX for a specific post, include math: true in the post\u0026rsquo;s frontmatter:\n--- title: \"My Math Post\" math: true ---Globally To enable KaTeX for all posts, set article.math to true in your site configuration (params.yaml or params.toml):\narticle: math: trueExamples Inline Math You can include math inline by wrapping the expression in single dollar signs $.\nFor example: $ \\varphi = \\dfrac{1+\\sqrt5}{2}= 1.6180339887… $ renders as $ \\varphi = \\dfrac{1+\\sqrt5}{2}= 1.6180339887… $\nBlock Math For larger equations, use double dollar signs $$ to create a math block.\n$$ \\varphi = 1+\\frac{1} {1+\\frac{1} {1+\\frac{1} {1+\\cdots} } } $$More Complex Formula $$ f(a) = \\frac{1}{2\\pi i} \\oint_\\gamma \\frac{f(z)}{z-a} dz $$ Note: For a full list of supported TeX functions, refer to the KaTeX documentation.\n","date":"2026-01-24T00:00:00Z","permalink":"/p/math-typesetting/","title":"Math Typesetting"},{"content":"Hugo is a powerful static site generator with many advanced features that can help you build better websites more efficiently.\nAdvanced Hugo Configuration Hugo\u0026rsquo;s configuration system is flexible and powerful. You can organize your configuration files in different ways to suit your project structure.\nUsing Config Directory Instead of a single config file, you can use a config directory:\nconfig/ ├── _default/ │ └── config.toml ├── production/ │ └── config.toml └── development/ └── config.tomlTemplate Inheritance Hugo\u0026rsquo;s templating system allows you to create reusable components and layouts.\nPartial Templates Partials are useful for organizing common template fragments:\n{{ partial \"header\" . }} {{ partial \"content\" . }} {{ partial \"footer\" . }}Content Organization Organizing your content structure properly can significantly improve your workflow.\nBranch Bundles Use branch bundles for better content organization:\ncontent/ ├── blog/ │ ├── _index.md │ ├── post-1/ │ │ └── index.md │ └── post-2/ │ └── index.mdPerformance Optimization Hugo builds websites incredibly fast, but there are still optimization techniques you can apply.\nUse asset bundling Minimize CSS and JavaScript Optimize images Leverage Hugo\u0026rsquo;s built-in resources processing Hugo makes it easy to build fast, secure, and scalable websites with minimal overhead.\n","date":"2026-01-20T00:00:00Z","permalink":"/p/hugo-advanced-tips-and-tricks/","title":"Hugo Advanced Tips and Tricks"},{"content":"Web design has evolved significantly over the past decade. Modern web design combines aesthetics with functionality to create engaging user experiences.\nDesign Principles Good web design follows several core principles that help create effective and user-friendly websites.\nVisual Hierarchy Visual hierarchy guides users through your content in order of importance.\nUse size and weight to emphasize key elements Apply color strategically Create clear sections and grouping Use whitespace effectively Responsive Design Every modern website needs to work well on all device sizes.\nMobile-First Approach Start designing for mobile devices first:\n/* Mobile styles (small screens) */ .container { width: 100%; padding: 1rem; } /* Tablet and larger */ @media (min-width: 768px) { .container { width: 90%; max-width: 1200px; margin: 0 auto; } }Typography Typography is crucial for readability and user experience.\nChoose fonts carefully for readability Maintain good line spacing Use appropriate font sizes Create visual rhythm with typography Color Theory Understanding color helps create visually appealing designs.\nUse complementary colors for contrast Apply the 60-30-10 color rule Consider accessibility for color-blind users Test color combinations Web design is an ongoing journey of learning and improvement.\n","date":"2026-01-18T00:00:00Z","permalink":"/p/web-design-basics-for-modern-websites/","title":"Web Design Basics for Modern Websites"},{"content":"CSS has evolved dramatically in recent years with powerful new features that make styling more efficient and flexible.\nCSS Grid Layout CSS Grid is a game-changer for creating complex layouts with minimal code.\nBasic Grid Setup .grid-container { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }CSS Flexbox Flexbox makes it easier to design flexible responsive layout structure.\nFlex Container .flex-container { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }CSS Variables Custom properties allow you to define reusable values in CSS.\n:root { --primary-color: #007bff; --secondary-color: #6c757d; --spacing-unit: 1rem; } .button { background-color: var(--primary-color); padding: var(--spacing-unit); }CSS Animations Create smooth animations without JavaScript.\n@keyframes slide-in { from { transform: translateX(-100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } } .element { animation: slide-in 0.3s ease-out; }Media Queries and Responsive Design Make your designs adapt to different screen sizes.\n@media (max-width: 768px) { .container { padding: 0.5rem; } }Modern CSS makes it easier to create beautiful, performant, and maintainable stylesheets.\n","date":"2026-01-15T00:00:00Z","permalink":"/p/modern-css-features-and-techniques/","title":"Modern CSS Features and Techniques"},{"content":"Static site generators have revolutionized how we build web projects. Let\u0026rsquo;s explore the most popular options available today.\nWhat are Static Site Generators? Static site generators are tools that create static HTML, CSS, and JavaScript from template files and content data.\nBenefits Speed: Pre-rendered pages are incredibly fast Security: No server-side code execution Simplicity: Easy to host and deploy Version Control: Content is usually stored in Git Scalability: Handle traffic spikes effortlessly Popular Static Site Generators Hugo Hugo is one of the fastest static site generators available.\nAdvantages:\nWritten in Go for exceptional speed Simple configuration Flexible template system Large community Jekyll Jekyll is the granddaddy of static site generators.\nAdvantages:\nIntegrated with GitHub Pages Built with Ruby Extensive theme ecosystem Great documentation Next.js A React-based framework with static generation capabilities.\nAdvantages:\nPowerful React ecosystem Hybrid static/dynamic rendering Great developer experience Enterprise-ready Choosing the Right Tool Consider these factors when selecting a static site generator:\nPerformance Requirements: Hugo excels in build speed Template Language: Choose based on your preference Community and Themes: GitHub Pages users often choose Jekyll Scalability Needs: All three handle large sites well Learning Curve: Hugo is easiest to learn for beginners Deployment Options GitHub Pages: Best with Jekyll Netlify: Works great with all generators Vercel: Optimal for Next.js Traditional Hosting: Works with any generator Static site generators are perfect for blogs, documentation sites, and marketing websites.\n","date":"2026-01-12T00:00:00Z","permalink":"/p/static-site-generators-comparison/","title":"Static Site Generators Comparison"},{"content":"Website performance directly impacts user experience and search engine rankings. Learn how to optimize your site for speed.\nUnderstanding Core Web Vitals Core Web Vitals are key metrics that Google uses to evaluate page experience.\nLargest Contentful Paint (LCP) LCP measures loading performance. Aim for LCP to occur within 2.5 seconds.\nOptimize server response time Optimize critical rendering path Improve resource load times Use Content Delivery Networks (CDNs) First Input Delay (FID) FID measures interactivity. Keep FID below 100 milliseconds.\nReduce JavaScript execution time Break up long JavaScript tasks Use web workers for heavy computation Optimize third-party scripts Cumulative Layout Shift (CLS) CLS measures visual stability. Keep CLS score under 0.1.\nReserve space for images and ads Avoid inserting content above existing content Use transform animations instead of layout changes Image Optimization Images often account for the majority of page load time.\nBest Practices Code Splitting and Lazy Loading Reduce initial bundle size with code splitting.\n// Dynamic imports for route-based splitting const Component = lazy(() =\u003e import('./Component')); // Intersection Observer for lazy loading const observer = new IntersectionObserver((entries) =\u003e { entries.forEach(entry =\u003e { if (entry.isIntersecting) { loadContent(); } }); });Caching Strategies Implement effective caching to reduce server load.\nBrowser caching with cache headers Service workers for offline support CDN caching for static assets Database query caching Tools for Performance Testing Google PageSpeed Insights WebPageTest Lighthouse GTmetrix Website performance optimization is an ongoing process that yields significant returns.\n","date":"2026-01-10T00:00:00Z","permalink":"/p/web-performance-optimization-guide/","title":"Web Performance Optimization Guide"},{"content":"Writing good frontend code requires discipline, knowledge, and a commitment to best practices. Let\u0026rsquo;s explore the key principles that every frontend developer should know.\nCode Organization Well-organized code is easier to maintain and extend.\nComponent-Based Architecture Organize your code into reusable, single-responsibility components.\n// Good: Single responsibility const Button = ({ label, onClick }) =\u003e ( {label} ); // Avoid: Too many responsibilities const UberComponent = ({ ...allProps }) =\u003e { // Trying to do everything };Error Handling Proper error handling makes applications more robust.\n// Good: Comprehensive error handling try { const response = await fetch(url); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return await response.json(); } catch (error) { console.error('Fetch failed:', error); // Handle error appropriately }Performance Considerations Minimize JavaScript Only load what you need Split code into smaller chunks Use tree-shaking to remove unused code Defer non-critical JavaScript Optimize Re-renders // Memoize expensive components const ExpensiveComponent = React.memo(({ data }) =\u003e { return {processData(data)}; });Accessibility Accessible websites work for everyone.\nSemantic HTML Home About ... ARIA Attributes ☰ Testing Testing catches bugs early and prevents regressions.\nUnit Tests: Test individual functions Integration Tests: Test how components work together E2E Tests: Test user workflows Accessibility Tests: Verify accessibility features Version Control Best Practices Write meaningful commit messages Keep commits atomic and focused Review code before merging Maintain clear branch strategies Documentation Good documentation makes your code more maintainable.\nDocument complex logic Provide usage examples Keep documentation updated Use JSDoc for function documentation /** * Calculate the sum of two numbers * @param {number} a - First number * @param {number} b - Second number * @returns {number} The sum of a and b */ function add(a, b) { return a + b; }Following these best practices leads to better code quality, maintainability, and user experience.\n","date":"2026-01-08T00:00:00Z","permalink":"/p/frontend-best-practices-and-code-quality/","title":"Frontend Best Practices and Code Quality"},{"content":"This theme supports Mermaid diagrams directly in your Markdown content. Mermaid lets you create diagrams and visualizations using text and code.\nAbout Mermaid.js This theme integrates Mermaid.js (v11) to render diagrams from text definitions within Markdown code blocks. Mermaid is a JavaScript-based diagramming and charting tool that uses text-based syntax inspired by Markdown.\nFor complete syntax documentation, see the Mermaid.js documentation.\nGetting Started To create a Mermaid diagram, simply use a fenced code block with mermaid as the language identifier:\n```mermaid graph TD A[Start] --\u003e B[Process] B --\u003e C[End] ```The diagram will be automatically rendered when the page loads.\nFeatures Auto-detection: Mermaid script only loads on pages that contain diagrams Theme Support: Diagrams automatically adapt to light/dark mode HTML Labels: Support for HTML content in labels (like \u0026lt;br/\u0026gt; for line breaks) Configurable: Customize version, security level, and more in your site config Configuration You can configure Mermaid in your site config:\nhugo.yaml:\nparams: article: mermaid: version: \"11\" # Mermaid version from CDN look: classic # classic or handDrawn (sketch style) lightTheme: default # Theme for light mode darkTheme: neutral # Theme for dark mode securityLevel: strict # strict (default), loose, antiscript, sandbox htmlLabels: true # Enable HTML in labelshugo.toml:\n[params.article.mermaid] version = \"11\" # Mermaid version from CDN look = \"classic\" # classic or handDrawn (sketch style) lightTheme = \"default\" # Theme for light mode darkTheme = \"neutral\" # Theme for dark mode securityLevel = \"strict\" # strict (default), loose, antiscript, sandbox htmlLabels = true # Enable HTML in labelsAdditional Global Options These optional settings use Mermaid\u0026rsquo;s defaults when not specified:\nhugo.yaml:\nparams: article: mermaid: maxTextSize: 50000 # Maximum text size (default: 50000) maxEdges: 500 # Maximum edges allowed (default: 500) fontSize: 16 # Global font size in pixels (default: 16) fontFamily: \"arial\" # Global font family curve: \"basis\" # Line curve: basis, cardinal, linear (default: basis) logLevel: 5 # Debug level 0-5, 0=debug, 5=fatal (default: 5)hugo.toml:\n[params.article.mermaid] maxTextSize = 50000 # Maximum text size (default: 50000) maxEdges = 500 # Maximum edges allowed (default: 500) fontSize = 16 # Global font size in pixels (default: 16) fontFamily = \"arial\" # Global font family curve = \"basis\" # Line curve: basis, cardinal, linear (default: basis) logLevel = 5 # Debug level 0-5, 0=debug, 5=fatal (default: 5)For diagram-specific options (like flowchart.useMaxWidth), use Mermaid\u0026rsquo;s init directive directly in your diagram:\n```mermaid %%{init: {'flowchart': {'useMaxWidth': false}}}%% flowchart LR A --\u003e B ``` Security Note: The default securityLevel: strict is recommended. Set to loose only if you need HTML labels like \u0026lt;br/\u0026gt; in your diagrams.\nAvailable Themes Theme Description default Standard colorful theme neutral Grayscale, great for printing and dark mode dark Designed for dark backgrounds forest Green color palette base Minimal theme, customizable with themeVariables null Disable theming entirely Custom Theme Variables For full control, use the base theme with custom variables:\nhugo.yaml:\nparams: article: mermaid: lightTheme: base darkTheme: base lightThemeVariables: primaryColor: \"#4a90d9\" primaryTextColor: \"#ffffff\" lineColor: \"#333333\" darkThemeVariables: primaryColor: \"#6ab0f3\" primaryTextColor: \"#ffffff\" lineColor: \"#cccccc\" background: \"#1a1a2e\"hugo.toml:\n[params.article.mermaid] lightTheme = \"base\" darkTheme = \"base\" [params.article.mermaid.lightThemeVariables] primaryColor = \"#4a90d9\" primaryTextColor = \"#ffffff\" lineColor = \"#333333\" [params.article.mermaid.darkThemeVariables] primaryColor = \"#6ab0f3\" primaryTextColor = \"#ffffff\" lineColor = \"#cccccc\" background = \"#1a1a2e\"Common variables: primaryColor, secondaryColor, tertiaryColor, primaryTextColor, lineColor, background, fontFamily\nNote: Theme variables only work with the base theme and must use hex color values (e.g., #ff0000).\nDiagram Types Flowchart Flowcharts are the most common diagram type. Use graph or flowchart with direction indicators:\nTD or TB: Top to bottom BT: Bottom to top LR: Left to right RL: Right to left flowchart LR A[Hard edge] --\u003e|Link text| B(Round edge) B --\u003e C{Decision} C --\u003e|One| D[Result one] C --\u003e|Two| E[Result two]Sequence Diagram Perfect for showing interactions between components:\nsequenceDiagram participant Alice participant Bob Alice-\u003e\u003eJohn: Hello John, how are you? loop Healthcheck John-\u003e\u003eJohn: Fight against hypochondria end Note right of John: Rational thoughts prevail! John--\u003e\u003eAlice: Great! John-\u003e\u003eBob: How about you? Bob--\u003e\u003eJohn: Jolly good!Class Diagram Visualize class structures and relationships:\nclassDiagram Animal \u003c|-- Duck Animal \u003c|-- Fish Animal \u003c|-- Zebra Animal : +int age Animal : +String gender Animal: +isMammal() Animal: +mate() class Duck{ +String beakColor +swim() +quack() } class Fish{ -int sizeInFeet -canEat() } class Zebra{ +bool is_wild +run() }State Diagram Model state machines and transitions:\nstateDiagram-v2 [*] --\u003e Still Still --\u003e [*] Still --\u003e Moving Moving --\u003e Still Moving --\u003e Crash Crash --\u003e [*]Entity Relationship Diagram Document database schemas:\nerDiagram CUSTOMER ||--o{ ORDER : places ORDER ||--|{ LINE-ITEM : contains CUSTOMER }|..|{ DELIVERY-ADDRESS : uses CUSTOMER { string name string custNumber string sector } ORDER { int orderNumber string deliveryAddress }Gantt Chart Plan and track project schedules:\ngantt title A Gantt Diagram dateFormat YYYY-MM-DD section Section A task :a1, 2024-01-01, 30d Another task :after a1, 20d section Another Task in Another :2024-01-12, 12d another task :24dPie Chart Display proportional data:\npie showData title Key elements in Product X \"Calcium\" : 42.96 \"Potassium\" : 50.05 \"Magnesium\" : 10.01 \"Iron\" : 5Git Graph Visualize Git branching strategies:\ngitGraph commit commit branch develop checkout develop commit commit checkout main merge develop commit commitMindmap Create hierarchical mindmaps:\nmindmap root((mindmap)) Origins Long history Popularisation British popular psychology author Tony Buzan Research On effectivenessand features On Automatic creation Uses Creative techniques Strategic planning Argument mapping Tools Pen and paper MermaidTimeline Display chronological events:\ntimeline title History of Social Media Platform 2002 : LinkedIn 2004 : Facebook : Google 2005 : YouTube 2006 : TwitterAdvanced Features HTML in Labels To use HTML in labels, you must set securityLevel: loose in your site config:\nhugo.yaml:\nparams: article: mermaid: securityLevel: loose htmlLabels: truehugo.toml:\n[params.article.mermaid] securityLevel = \"loose\" htmlLabels = trueThen you can use HTML tags like \u0026lt;br/\u0026gt; for line breaks:\n```mermaid graph TD A[Line 1Line 2] --\u003e B[Bold text] ```Per-Diagram Theming Override the theme for a specific diagram using Mermaid\u0026rsquo;s frontmatter:\n```mermaid %%{init: {'theme': 'forest'}}%% graph TD A[Start] --\u003e B[End] ```%%{init: {'theme': 'forest'}}%% graph TD A[Christmas] --\u003e|Get money| B(Go shopping) B --\u003e C{Let me think} C --\u003e|One| D[Laptop] C --\u003e|Two| E[iPhone] C --\u003e|Three| F[Car]Inline Styling with style You can style individual nodes directly within your diagram using the style directive:\n```mermaid flowchart LR A[Start] --\u003e B[Process] --\u003e C[End] style A fill:#4ade80,stroke:#166534,color:#000 style B fill:#60a5fa,stroke:#1e40af,color:#000 style C fill:#f87171,stroke:#991b1b,color:#fff ```Result:\nflowchart LR A[Start] --\u003e B[Process] --\u003e C[End] style A fill:#4ade80,stroke:#166534,color:#000 style B fill:#60a5fa,stroke:#1e40af,color:#000 style C fill:#f87171,stroke:#991b1b,color:#fffStyle properties include:\nfill - Background color stroke - Border color stroke-width - Border thickness color - Text color stroke-dasharray - Dashed border (e.g., 5 5) Styling with CSS Classes You can define reusable styles with classDef and apply them using :::className:\n```mermaid flowchart LR A:::success --\u003e B:::info --\u003e C:::warning classDef success fill:#4ade80,stroke:#166534,color:#000 classDef info fill:#60a5fa,stroke:#1e40af,color:#000 classDef warning fill:#fbbf24,stroke:#92400e,color:#000 ```Result:\nflowchart LR A:::success --\u003e B:::info --\u003e C:::warning classDef success fill:#4ade80,stroke:#166534,color:#000 classDef info fill:#60a5fa,stroke:#1e40af,color:#000 classDef warning fill:#fbbf24,stroke:#92400e,color:#000Subgraphs Group related nodes together:\nflowchart TB subgraph one a1--\u003ea2 end subgraph two b1--\u003eb2 end subgraph three c1--\u003ec2 end one --\u003e two three --\u003e two two --\u003e c2Theme Switching This theme automatically detects your site\u0026rsquo;s light/dark mode preference and adjusts the Mermaid diagram theme accordingly:\nLight mode: Uses the default Mermaid theme Dark mode: Uses the dark Mermaid theme (configurable) Try toggling the theme switcher to see diagrams update in real-time!\nComplex Example Here\u0026rsquo;s an example with subgraphs, HTML labels, emojis, and custom styling:\nflowchart TD subgraph client[\"👤 Client\"] A[\"User Device192.168.1.10\"] end subgraph cloud[\"☁️ Cloud Gateway\"] B[\"Load Balancer(SSL Termination)\"] end subgraph server[\"🖥️ Application Server\"] C[\"API Gateway10.0.0.1\"] D[\"Auth Service10.0.0.2\"] E[\"Web Server10.0.0.3\"] F[\"Database10.0.0.4\"] end A -- \"HTTPS Request\" --\u003e B B -- \"Forward(internal)\" --\u003e C C -- \"Authenticate\" --\u003e D D -- \"Token\" --\u003e C C -- \"Route\" --\u003e E E --\u003e F style client fill:#1a365d,stroke:#2c5282,color:#fff style cloud fill:#f6ad55,stroke:#dd6b20,color:#000 style server fill:#276749,stroke:#22543d,color:#fff Note: This example requires securityLevel: loose for HTML labels and styling to work.\nKnown Limitations Dark Mode Theming Mermaid.js\u0026rsquo;s built-in themes have some limitations:\ndark theme (default): Best text contrast, but some diagram backgrounds may appear brownish (e.g., Gantt charts) neutral theme: Better background colors, but some text (labels, legends) may have reduced contrast For full control, use the base theme with custom variables:\nhugo.yaml:\nparams: article: mermaid: darkTheme: base darkThemeVariables: primaryColor: \"#1f2937\" primaryTextColor: \"#ffffff\" lineColor: \"#9ca3af\" textColor: \"#e5e7eb\"hugo.toml:\n[params.article.mermaid] darkTheme = \"base\" [params.article.mermaid.darkThemeVariables] primaryColor = \"#1f2937\" primaryTextColor = \"#ffffff\" lineColor = \"#9ca3af\" textColor = \"#e5e7eb\"We plan to improve dark mode theming in future updates as Mermaid.js evolves.\nTroubleshooting Diagram not rendering? Make sure you\u0026rsquo;re using a fenced code block with mermaid as the language Check your browser\u0026rsquo;s console for syntax errors Verify your Mermaid syntax at Mermaid Live Editor HTML not working in labels? HTML in labels requires securityLevel: loose. Update your configuration:\nhugo.yaml:\nparams: article: mermaid: securityLevel: loose htmlLabels: truehugo.toml:\n[params.article.mermaid] securityLevel = \"loose\" htmlLabels = true Warning: Using loose security level allows HTML in diagrams. Only use this if you trust your diagram content.\nSyntax errors? Mermaid is strict about syntax. Common issues:\nMissing spaces around arrows Unclosed brackets or quotes Invalid node IDs (avoid special characters) Resources Mermaid Documentation Mermaid Live Editor - Test diagrams interactively Mermaid Syntax Reference ","date":"2025-12-23T00:00:00Z","permalink":"/p/mermaid-diagrams/","title":"Mermaid Diagrams"}]