Local Images
You can use local images stored in your public directory:

External Images
You can also use images from trusted external sources:
From Unsplash
From GitHub

From Cloudinary

Mermaid Diagrams
You can create flowcharts, sequence diagrams, and more using Mermaid:
Flowchart Example
Sequence Diagram
Class Diagram
Advanced Flowchart
Advanced Sequence Diagram
Advanced Class Diagram
Mathematical Equations
You can write both inline math like and display math:
Here's Maxwell's equations:
And a matrix:
Basic Math
Inline equations like or are written between single dollar signs.
Display equations use double dollar signs:
Complex Mathematics
The Schrödinger equation:
A complex matrix equation:
Maxwell's equations in differential form:
Statistical Formulas
The normal distribution probability density function:
Combining Features
You can even explain algorithms with both diagrams and equations:
Combining Math and Diagrams
Here's a flowchart explaining the quadratic formula:
Best Practices
-
For Local Images:
- Store in
/public/images/blog/ - Use relative paths starting with
/images/blog/ - Optimize before uploading
- Store in
-
For External Images:
- Only use trusted sources (configured in next.config.mjs)
- Specify dimensions when possible
- Use auto-formatting URLs (like Unsplash's auto=format)
-
For Mermaid Diagrams:
- Keep diagrams simple and focused
- Use consistent styling
- Add comments for complex parts
-
For Mathematical Equations:
- Use inline math () for simple expressions
- Use display math () for complex equations
- Break complex equations into multiple lines
- Add explanatory text around equations
-
Performance Tips:
- Use WebP format when possible
- Set
priority={true}for above-the-fold images - Specify width and height to prevent layout shift
- Use responsive images for different screen sizes
Note: Make sure external domains are added to the
remotePatternsin next.config.mjs!
Using HTML for More Control
For more control over your images, use HTML with Next.js Image component:
<Image src="https://images.unsplash.com/photo-1682687220742-aba13b6e50ba" alt="Controlled image example" width={800} height={400} className="rounded-lg shadow-md my-4 mx-auto" priority={true} />