Introduction
In 2017, I published the first version of Build Blog With Wagtail CMS, which aims to teach people how to build a modern blog using Wagtail CMS. (Wagtail 1.10.1, Django 2.2)
2.0.0
is released in Jan 2021 (Wagtail 2.11, Django 3.1)3.0.0
is released in Aug 2021 (Wagtail 2.14, Django 3.2)
Today, 4.0.0
is finally released! 😀
What is New
Wagtail 4
Below are some important changes in Wagtail 4
- Wagtail 4 brings significant UI changes that affect all of Wagtail’s admin
- The richtext editor is more powerful, for example, it has
command palette
- Live preview can let you check the page content real time.
You can check Wagtail 4 release notes to know more.
In this book, we will use Wagtail 4 and Django 4, both are the latest version.
Tailwind CSS
Bootstrap
is a little outdated, now more and more people are using Tailwind CSS
Tailwind CSS
is a utility-first CSS framework for rapidly building custom user interfaces
If you have no idea what it is, please check the official website to learn more.
We will use Tailwind CSS as our style solution and learn some interesting stuff such as typography plugin
and dark mode with css class
FYI Wagtail admin also starts using Tailwind CSS
https://github.com/wagtail/wagtail/blob/v4.1/client/tailwind.config.js
Stimulus
jQuery is obsolete and we should stop using it.
What should we do if we need to write some Javascript to do some DOM manipulation?
We need a lightweight but powerful javascript framework, which works fine as our project grow, and it should be easy to learn because many Wagtail developers do not want to touch heavy frontend frameworks such as React, Vue.
Stimulus is a good fit
Stimulus
is the official frontend solution shipped withRuby on Rails
, and it can also work with any backend framework such as Django, Laravel- If you have no idea what
Stimulus
is, please visit Stimulus Doc to do quick check
In this book, I will teach you how to use Stimulus to write reusable
Stimulus controller to manipulate DOM, handle DOM events.
BTW, Wagtail team also decided to use Stimulus
to replace jQuery in Wagtail admin
, here is the PR https://github.com/wagtail/rfcs/pull/78 if you want to know more.
Objective
This book will teach you how to build a modern blog with Wagtail CMS
By the end of this course, you will be able to:
- Understand
Docker
and useDocker Compose
to do development - Use
python-webpack-boilerplate
to jump start frontend project bundled by Webpack. - Install
Tailwind CSS
as the style solution. - Install
Stimulus
, understand how it works and write Stimulus controllers. - Learn how
Dark Mode
works in Tailwind CSS and use Stimulus controller to toggle the dark mode. - Understand the benefit of the healthy Stimulus ecosystem by reusing 3-party Stimulus controller.
- Create blog models to work with Wagtail.
- Use
PDB
andDjango shell
to debug, test code and check data in terminal. - Learn to use
RoutablePage
and addDate
to the post url. - Build
Pagination
component and correctly handle querystring. - Make the blog supports writing in
Markdown
andLatex
. - Create contact page using Wagtail
FormBuilder
- Build menu, meta tags, sitemap, robots.txt for better SEO.
- Build comment system based on
django-contrib-comments
which supportGeneric Relations
- Use
Tribute.js
,Axios
to addMention
andEmoji
support to the comment form. - Deploy the production app to DigitalOcean
Tech
- Python 3.10
- Django 4
- Wagtail 4
- Stimulus 3
- Tailwind CSS 3
What included
- A PDF ebook which contains about 30 chapters.
- 20+ screenshots and several diagrams, all created by me.
- The source code is available on the Github/wagtail-tailwind-blog
Demo
The demo is also online if you want to check.
Table of Contents
- Introduction
- Create Wagtail Project
- Create Frontend App
- Dockerizing Wagtail App
- Add Blog Models to Wagtail
- Page Templates in Wagtail
- Build Page Layout with Tailwind CSS
- StreamField in Wagtail
- Routable Page
- Add Pagination Component
- Add Date to the PostPage URL
- Full Text Search
- Markdown Support
- Customize Markdown Renderer
- Build Flexible Form Page
- Menu Management
- Wagtail SEO Guide
- Stimulus Basic
- Dark Mode
- Tailwind Typography Dark Mode
- Carousel
- Comment Model
- Customize Django-Contrib-Comments
- Manage Comment in Wagtail
- Add Mention Support to Django Form with Tribute.js
- Add Emoji Support to Django Form with Tribute.js
- Deploy to DigitalOcean
- Next Steps
- Backend FAQ