Skip to main content

Hands-On Projects

Project 4: Build a Markdown to HTML Converter

Learn how to build a Markdown to HTML converter in Go using the goldmark package. Covers io.Reader, bytes.Buffer, stdin piping, and file redirection.

In Project 3, you built a task manager that reads and writes data to a local file, where you saw how Go handles file I/O with os.ReadFile and os.WriteFile, and how json.Unmarshal turns raw bytes into usable Go structs.

This project builds on that same foundation, but takes it further. Instead of structured JSON data, we are now working with real text files - reading Markdown content, transforming it, and writing the result as HTML.

By the end, you will have a tool you can actually use on your own projects.

What is Markdown?

Markdown is a popular, lightweight text markup language created in 2004 with the goal of making plain text files easy to write and more readable.

It lets you define headings, apply bold or italic styles, add links, and create lists all using simple characters that look natural even before they are rendered.

Over time, Markdown became the standard format across most developer tools and GitHub uses it for README files and project descriptions.

GitLab, Reddit, and many blog platforms like Hugo and Ghost do the same. If you write documentation or publish technical content, you are almost certainly working with Markdown already.

What We Will Build

Our tool will accept Markdown input in two ways:

  • A file passed as a command-line argument: go run md2html.go README.md > index.html
  • Piped text directly from the terminal: echo "# Markdown Heading" | go run md2html.go

The converted HTML will be printed to standard output, so you can either read it in the terminal or redirect it to a file.

This dual-input design introduces a new Go concept called io.Reader, that you will use frequently in real-world programs.

Create the Project

Pro TecMint Β· Root Plan
This Article is for Root Members
Join Root to read the full article and unlock everything

Full Access to Every Article, Course & Certification Track

Join thousands of Linux professionals who use Pro TecMint to advance their careers.

Ad-free access to all premium articles
All courses: Learn Linux, Bash, Golang, Ubuntu and more
RHCSA, RHCE, LFCS & LFCA certification prep
New courses added every month
Private Telegram community & priority support
Root Plan
$8/mo
or $59/year billed annually
Save $37 with annual plan
Start Reading This Article in the Next 60 Seconds
Join Root Plan β†’