Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

RubyintermediatecliAI generated

Markdown Publishing CLI

Build a Ruby command-line tool that turns a folder of Markdown articles into a ready-to-publish website. Each article starts with front matter (title, date, tags, a draft flag); the tool checks it strictly and reports every problem, creates clean URL slugs, converts Markdown to HTML with a layout template, and builds index and tag pages. The output is deterministic: building the same input twice produces exactly the same files, byte for byte, so only real changes show up when you deploy or compare. Unchanged articles are skipped to keep builds fast. You'll learn parsing front matter with YAML, validation, slug rules, templates with ERB, Markdown with Kramdown, deterministic builds, and packaging a tool as a gem.

Estimate
~10.5h
Steps
6
Completed by
0
Proposed by
codeseed.app

RubyGems · Kramdown · ERB

Project roadmap

  1. 01

    Define the rules

    ~1.5h

    Write README.md: the input folder structure, the front matter fields (title required, date required in YYYY-MM-DD, tags as a list, draft optional, slug optional), how slugs are made (from the title: lowercase, accents removed, dashes, and must be unique), the output structure (/posts/slug/index.html, /tags/tag/index.html and an index page), and the command (publish build SRC OUT, with --drafts). Create a gem skeleton with bundle gem. Done when: README.md defines the rules and output.

  2. 02

    Parse and validate front matter

    ~2h

    Split each file into front matter and body, and parse the front matter with YAML.safe_load (allowing only simple types and dates). Validate each field and collect every error with the file name, then print them all together and exit with code 1 before writing anything. Check slugs are unique across all articles. Done when: a folder with several mistakes reports all of them at once.

  3. 03

    Render pages

    ~2h

    Convert Markdown to HTML with Kramdown, and render pages with ERB layout templates for articles, the index (newest first) and tag pages, escaping titles and tags. Leave out drafts unless --drafts is given. Write each page to its folder. Done when: building a sample folder produces a working website you can open in a browser.

  4. 04

    Make builds deterministic

    ~1.5h

    Make sure the same input always produces the same bytes: sort everything that's listed (articles by date then slug, tags alphabetically), never include the build time in pages, use fixed line endings, and write files only when their content changed. Add a check command that builds twice into temporary folders and compares them. Done when: building twice gives identical files, and the check command passes.

  5. 05

    Skip unchanged work and clean up

    ~1.5h

    Keep a manifest of each input's content hash and the pages it produced, rebuilding only articles that changed (and the index and tag pages when any article's title, date or tags changed). Remove output files for deleted articles. Write output to a temporary folder and move it into place so a failed build never leaves a half-updated site. Done when: rebuilding after changing one article only rewrites that article and the affected lists.

  6. 06

    Test it

    ~2h

    Write RSpec or Minitest tests: front matter parsing and every validation rule, slug generation (accents, punctuation and duplicates), drafts, deterministic output (building twice), incremental builds, and removed articles. Done when: all tests pass.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~10.5h · 6 steps

Tech stack

RubyGemsKramdownERB