Skip to content

Images

DocsForge handles images with enhanced styling options. Images are responsive by default and support lazy loading, alignment, sizing, and more.


Basic image

Standard Markdown syntax:

![Alt text](../assets/images/screenshot.svg)

Alt text

Always use descriptive alt text for accessibility and SEO.


Image with caption

Use figure markup for captions:

<figure markdown="span">
  ![Screenshot](../assets/images/screenshot.svg)
  <figcaption>Documentation site preview</figcaption>
</figure>

Screenshot


Documentation site preview


Image alignment

Left aligned

![Image](../assets/images/screenshot.svg){ align=left }

Text wraps around the image on the right.

Right aligned

![Image](../assets/images/screenshot.svg){ align=right }

Text wraps around the image on the left.

Center aligned

![Image](../assets/images/screenshot.svg){ align=center }

Image is centered with text above and below.


Image size

Set width and height:

![Image](../assets/images/screenshot.svg){ width="300" }

Set width as a percentage:

![Image](../assets/images/screenshot.svg){ width="50%" }

Set both width and height:

![Image](../assets/images/screenshot.svg){ width="300" height="200" }

Aspect ratio

Setting both width and height may distort the image. Use width alone to maintain aspect ratio.


Lazy loading

Images load lazily by default. To disable for above-the-fold images (like hero banners):

![Hero image](assets/images/hero.png){ loading=eager }
ValueBehavior
lazy (default)Load when image enters viewport
eagerLoad immediately with page

Shadow effect

Add a subtle shadow for depth:

![Image](../assets/images/screenshot.svg){ .shadow }

This works well for screenshots and UI mockups to separate them from the page background.


Linking images

Make an image a link:

[![Alt text](../assets/images/screenshot.svg)](https://example.com)

Open in new tab:

[![Alt text](../assets/images/screenshot.svg)](https://example.com){ target="_blank" }

DocsForge supports lightbox mode for images. Click any image to see it full size:

![Diagram](assets/images/diagram.png){ data-lightbox }

This is enabled automatically for most images. No configuration needed.


Create a grid of images:

<div class="grid" markdown>

![Image 1](assets/images/1.png)
![Image 2](assets/images/2.png)
![Image 3](assets/images/3.png)

</div>

Responsive images

DocsForge automatically makes images responsive. They:
- Scale to fit their container
- Never overflow the content area
- Maintain aspect ratio
- Work on all screen sizes

No configuration needed.


Image formats

Recommended formats:

FormatBest forSize
SVGLogos, icons, diagramsSmallest, infinite scale
WebPScreenshots, photos~25% smaller than PNG/JPEG
PNGScreenshots with transparencyLossless, larger
JPEGPhotos without transparencyGood compression

Convert to WebP

# Using cwebp
cwebp -q 85 image.png -o image.webp

# Using ImageMagick
convert image.png -quality 85 image.webp

Optimization tips

  1. Use WebP when possible — smaller than PNG/JPEG with similar quality
  2. Compress images before adding to docs (use tinypng.com, ImageMagick, or ffmpeg)
  3. Use SVG for logos, icons, and simple diagrams
  4. Keep under 200KB when possible — larger images slow page load
  5. Use descriptive alt text — important for accessibility and SEO
  6. Lazy load by default — only use eager for above-the-fold images
  7. Consider dark mode — use transparent PNGs or SVGs for dark theme compatibility

Image sizing guidelines

TypeRecommended sizeFormat
Logo200×50pxSVG
Screenshot800-1200px wideWebP/PNG
DiagramVectorSVG
Icon24×24pxSVG
Hero banner1200×400pxWebP/JPEG

Next steps