Don't store content as HTML - It's a trap
Rich HTML Editors make your life easier at the beginning and produce content that looks nice and clean, but behind the scenes, it generates HTML which can get out of control quickly especially if you need to edit the source code (E.g. include a special style). It becomes incredibly difficult to maintain over time.
Some examples of rich HTML editors that you can embed in your web applications:
Note: None of these are recommended because of the HTML that is generated.
-
- Figure: Bad example - HTML generated by a rich editor gets harder to maintain over time.
This link shows many things that have to be fixed in bad HTML:
https://www.diffchecker.com/CIGu4K19.
Store content in Markdown
Content is typically either stored in files (eg. git) or a database. When stored in files, it is common to use a static site generator with a JAMStack approach. (eg. Gatsby, Vuepress, Hexo, etc) That is, you commit content into git and a CI/CD pipeline is executed. The resulting files (html and css) are then served from storage which is cheaper and typically more scalable than compute resources in the cloud. In this case, the workflow will be a development style workflow (commit to git, push, etc) and the editor will be the one you choose. (e.g. GitHub editor or VS Code) These editors are not likely to produce a rich editing experience, nor do they need to.
For a non-technical audience, it helps to store your content as markdown in a database and convert to HTML on the fly. This removes the code repository/CI/CD pipelines and can feel more natural for a non-developer audience. In this case, you will provide an editor and it is recommended that this be a rich editor.
Markdown rich editors
The Markdown rich editors are not as good as the HTML ones, but at least the content they produce is maintainable over time.
Some example of rich Markdown editors are:
-
- Figure: Good example - Markdown looks clean
Markdown can have rich content too
Markdown is simple and limited, but you can make it richer.
One way is to use inline HTML, this allows you to use HTML tags that you are familiar with (only if you need to) and embed things like YouTube videos or JavaScript.
-
- Figure: OK Example – you can use raw HTML in your Markdown, and mostly it will work pretty well. But you can’t use Markdown’s syntactic sugar in the HTML
The other way is to use templates or containers:
-
- Figure: Bad Example – The danger of using HTML in your Markdown files is that you add too much formatting e.g. use Bootstrap classes that create tight coupling between the content and the presentation
A better way is to use a plugin (if your Markdown engine supports it).
-
- Figure: Good Example – VuePress has a custom container that generates nice alert boxes like Bootstrap but without tying the presentation to the CSS framework in the content
Unfortunately, Markdown does not support YouTube videos embedding out of the box. However, there is a workaround to embed it.
[](http://www.youtube.com/watch?v=dQw4w9WgXcQ)

Figure: Good Example - Workaround to embed YouTube video using YouTube's generated thumbnail
If your site is using "markdown-it" parser, you can also install "markdown-it-video" to allow YouTube video directly embedded into the page, rather than providing just an image and a link.
@[youtube](http://www.youtube.com/embed/dQw4w9WgXcQ)

Figure: Better Example - YouTube video embedding using plugin
Markdown to HTML rendering processes
-
- Figure: The markdown rendered either Client-side or Server-side