Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Wagtail
  3. Wagtail Code Block

Wagtail Code Block

BSD-3-ClausePython1.30.0.0

A Wagtail CMS StreamField block for displaying source code with real-time PrismJS syntax highlighting in both admin and frontend.

GitHubGitHub
172 stars32 forks0 contributors

What is Wagtail Code Block?

Wagtail Code Block is a Django/Wagtail extension that adds a StreamField block for displaying source code with syntax highlighting. It solves the problem of presenting code snippets in Wagtail-powered websites by providing real-time highlighting in both the admin interface and frontend using PrismJS. The package makes it easy for content editors to add properly formatted code without needing technical markup knowledge.

Target Audience

Wagtail CMS developers and content editors who need to display code snippets in their websites. It's particularly useful for technical documentation sites, educational platforms, and developer blogs built with Wagtail.

Value Proposition

Developers choose Wagtail Code Block because it provides seamless integration with Wagtail's StreamField system, requires minimal configuration, and offers consistent syntax highlighting across both admin and frontend interfaces. Unlike generic code display solutions, it's specifically designed for Wagtail's architecture and editor workflow.

Overview

StreamField code blocks for the Wagtail CMS with real-time PrismJS Syntax Highlighting.

Use Cases

Best For

  • Adding code snippets to Wagtail blog posts and articles
  • Creating technical documentation sites with Wagtail CMS
  • Building educational platforms that require code examples
  • Displaying API examples in developer documentation
  • Showing configuration examples in tutorials and guides
  • Presenting code samples in portfolio sites for developers

Not Ideal For

  • Projects not built with Wagtail CMS, as it's tightly integrated and won't work with other frameworks or standalone Django
  • Applications requiring syntax highlighting without JavaScript, since frontend rendering depends on PrismJS client-side execution
  • Teams needing to use a different syntax highlighting library like Highlight.js, due to hard-coded PrismJS integration
  • High-performance websites where minimizing JavaScript bundle size is critical, as PrismJS can add significant weight

Pros & Cons

Pros

Real-time Admin Highlighting

Provides immediate syntax highlighting in the Wagtail editor as content editors type, enhancing the editing experience without page reloads, as shown in the screenshot.

Frontend PrismJS Integration

Uses PrismJS to deliver consistent, beautifully formatted code on the frontend with support for multiple themes like Coy, Dark, and Okaidia, configurable via Django settings.

Built-in Usability Features

Includes line numbers and a copy-to-clipboard button by default, both configurable through settings like WAGTAIL_CODE_BLOCK_LINE_NUMBERS and WAGTAIL_CODE_BLOCK_COPY_TO_CLIPBOARD.

Extensive Language Support

Supports dozens of programming languages from Python to YAML, with a customizable language list via WAGTAIL_CODE_BLOCK_LANGUAGES, including esoteric options like Brainfuck and Zig.

Cons

PrismJS Lock-in

The project is hardcoded to use PrismJS, making it difficult to switch to alternative syntax highlighters without forking or significant customization, limiting flexibility.

Versioning Complexity

Version numbers are tied to PrismJS releases (e.g., 1.28.0.X), which can confuse dependency management and require careful matching with Wagtail versions, as noted in installation instructions.

JavaScript Dependency

Frontend highlighting relies on PrismJS JavaScript, so it won't work in environments with JS disabled or where server-side rendering is preferred for performance or accessibility.

Wagtail-Only Scope

Designed exclusively for Wagtail's StreamField, so it's unusable for projects outside Wagtail or those needing syntax highlighting in other parts of a Django app without Wagtail.

Frequently Asked Questions

Quick Stats

Stars172
Forks32
Contributors0
Open Issues5
Last commit4 months ago
CreatedSince 2017

Tags

#admin-interface#code-blocks#content-management#syntax-highlighting#python-web#wagtail-cms#prismjs#frontend-integration#django#streamfield

Built With

P
PrismJS
D
Django
P
Python
W
Wagtail

Included in

Wagtail2.2k
Auto-fetched 8 hours ago

Related Projects

Wagtail BlocksWagtail Blocks

A Collection of awesome Wagtail CMS stream-field blocks and Charts.

Stars80
Forks18
Last commit2 years ago
wagtail-inventorywagtail-inventory

Search Wagtail pages by the StreamField blocks they contain

Stars64
Forks21
Last commit1 month ago
Wagtail CommonblocksWagtail Commonblocks

Common StreamField blocks for Wagtail

Stars40
Forks10
Last commit5 years ago
Wagtail ClearStreamWagtail ClearStream

A work-in-progress app to make Wagtail's StreamField more modular

Stars35
Forks7
Last commit6 years ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub