How I Built a Blog with Astro and Claude Code

5 min read By Simple Tech Path

The short answer

You can build a fast, free-to-run blog by starting from an open-source Astro template, letting an AI coding assistant like Claude Code do the typing, and keeping the decisions for yourself. That is exactly how this site was made. The software costs nothing: the template is open source under the MIT license, and the only things I paid for were the domain and the hosting.

This article walks through what I did, what the project looks like and the one real bug I hit.

What I wanted

I wanted a small blog with plain pages (About, Contact, Privacy Policy), articles written in simple text files, and no database. I did not want WordPress, because I did not want to maintain plugins and updates for a site that only shows text and images.

A static site generator fits that. It turns your files into plain HTML pages once, and those pages can be uploaded to almost any hosting.

What I used

  • Astro, a static site generator. It builds the pages and a sitemap.
  • astro-zen-blog, a free blog template under the MIT license. I started from it and removed the example articles.
  • Tailwind CSS, which the template uses for styling.
  • Claude Code, an AI coding assistant, running inside VS Code. It wrote and edited the files while I made the decisions.
  • GitHub, with a private repository for the code.

Diagram of the workflow: my decisions, Claude Code writes the files, Astro builds the pages, GitHub checks the build and the dist folder goes to hosting

How the project is organized

Everything that matters lives in a few places:

  • src/config.ts holds the site title, slogan, description and contact email. It also has two empty fields for analytics and ads, which stay empty until I am ready, so nothing from those services loads on the site.
  • src/pages/ has the pages: Home, Blog, Tags, Archive, About, Contact and Privacy Policy.
  • src/content/blog/ is where articles go, one text file per article.
  • public/ holds files that are served as they are, such as images.

Each article starts with a short block of settings at the top: title, description, date, tags and a draft flag. Setting draft: true is meant to keep the article off the site while I am still working on it.

What Claude Code did

I told it what I wanted in plain language, and it created and edited the files. For example, it removed the sample articles from the template, wrote the first versions of the About, Contact and Privacy Policy pages, and set up the config file.

I did not accept things blindly. The About and Privacy Policy pages are drafts that I have to read myself, because they say things about me and about the site, and I am the one responsible for them. Anything on the site has to be true, so a human has to read it.

It also wrote two small helpers for me. One creates a new article from a template with npm run new-post. The other, npm run check:posts, reads every article that is not a draft and complains if it has no description, no tag, too few words, no image with alt text, or leftover placeholder text.

The GitHub check

I added a small workflow file so GitHub builds the site every time I push code or open a pull request. It installs the packages with npm ci and then runs npm run build. If the site stops building, I find out before anything goes live. When I set it up, the first run passed.

The build

Running npm run build creates a folder called dist. That folder is the whole website: plain HTML, CSS and files. When the blog had no articles yet, the build produced 8 pages. Uploading the dist folder to a hosting plan is all it takes to publish, and I have not published yet because the blog does not have enough real articles.

When I first installed the packages on my PC, npm warned that it blocked install scripts for two packages, esbuild and sharp. The build still worked, so I left it alone. If you see the same warning and the build runs, it is not a blocker, but it is worth watching if image processing ever fails.

The bug I found: drafts were being built

This is the part I like most, because it shows why you should check an AI’s work.

The template had a setting for draft articles, and the home page and article lists correctly hid them. But the page that creates each article’s own URL did not check the draft flag. It asked for every article and built a page for all of them. That means a draft would have been published on the web, even though it never appeared in any list.

I found this while I was adding my first draft articles. The fix was one line: when the page asks for the list of articles, it now skips anything marked as a draft. After the change, I ran the build again and confirmed that the draft did not appear in the dist folder.

If you start from a template, test your draft setting early. Create one draft article, build the site and look inside the output folder.

What I would tell a beginner

  • Start from a template instead of an empty folder. It is much easier to change something that works.
  • Keep the first version small. Pages first, articles later.
  • Read what the assistant writes, especially text that talks about you.
  • Test the boring things, like drafts, before you rely on them.
  • Keep ads and analytics switched off until the site has real content.

Frequently asked questions

Is Astro free? Yes. Astro and the template I used are open source and free. You still pay for a domain and hosting.

Do I need to know how to code? It helps to be comfortable with a terminal, but an assistant like Claude Code can do most of the typing. You still need to read the results and decide what is right.

Why not WordPress? For a site that is mostly text, a static site is simpler to host and I did not want to manage plugins and updates.

Where do I upload the site? After npm run build, upload the contents of the dist folder to your hosting.