Skip to content

Templates and Build

You'll move your site into a static site generator so the header lives in one file, the blog builds itself, and every push deploys.

About

By the tenth page, hand-writing the nav into every file is a bug waiting to happen. A static site generator takes templates and content and turns them into plain HTML. Eleventy, Hugo, Astro, Jekyll and Zola all do this well, so pick one by the language you already have installed, move your site into it, and deploy on every push. The output is still just files, which is the whole point.

At a glance

Per requirement
35 XP
Completion bonus
300 XP
Requirements
6
Takes
Three weeks
Skill level
Intermediate (months of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own
Locked for now
Earn two more Uncommon badges in Web Building to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Pick a generator and build its starter locally. Choose by the language you already have installed, and follow the quick start until a page builds. Take a screenshot of the terminal showing the build and the local preview. Photo
  2. 2
    Move your existing pages into one layout template. Make one base layout with the head, the header, the nav and the footer, so each page becomes just its content plus a title. Delete the duplicated markup. Take a screenshot of the layout file and one page file. Photo
  3. 3
    Turn your blog posts into a collection. Write each post as a Markdown file with front matter for the title and date. The archive page and the feed then generate from the collection. Take a screenshot of the generated archive next to the source files. Photo
  4. 4
    Deploy from a git push. Connect the repository to your host so every push to main rebuilds and publishes the site. Film a push followed by the deploy log turning green. Video
  5. 5
    Compare the generated HTML with your old site. Open a page from before and the same page from after. A visitor should see no difference, so fix whatever changed. Take a screenshot of the two pages side by side. Photo
  6. 6
    Write a README that gets you building again in six months. Cover the install steps, the build command, where the content lives and how to deploy. Future you will have forgotten all of it. Take a screenshot of the README. Photo