The essentials

Hello World tutorial

Build your first website, one file at a time.

You will create a small website, change its greeting, add an interactive accordion, make a second page, and publish it. No React experience is needed; basic HTML is enough.

Open the finished website or browse the starter source.

Before you begin

Install Node.js 22 or newer (npm comes with it), Git, and a code editor. Check your terminal:

node --version
npm --version
git --version

The CLI currently runs from a source checkout. There is no published blocks-ui npm package, so do not substitute npx blocks-ui or create-react-app for these commands.

1. Create your website

Run these commands from a folder where you keep projects. They create two sibling folders: the library checkout and your own website.

git clone https://github.com/gargadobe/blocks-ui.git
cd blocks-ui
npm ci
cd ..
node blocks-ui/packages/cli/index.js create my-first-site --template hello-world
cd my-first-site
npm install
npm run dev

Open http://127.0.0.1:3000/. You should see Hello, world!

Leave that terminal running. Open my-first-site in your editor. The generated website owns its block source and build tools; it does not depend on the checkout at runtime.

If port 3000 is already in use, stop this command with Ctrl+C and choose another port. On macOS/Linux run PORT=3001 npm run dev; in PowerShell run $env:PORT=3001; npm run dev. Use the URL printed in your terminal.

2. Make your first edit

Open pages/index.html. Change Hello, world! to Hello, Ada!, save, and watch the browser reload. Use your own name if you prefer.

The text between --- markers is front matter. It sets the page title and description. Everything below the closing marker is ordinary HTML.

Here is the small set of files you will work with:

my-first-site/
  pages/index.html        Home page
  layouts/default.html    Shared HTML document
  fragments/nav.html      Shared navigation
  fragments/footer.html   Shared footer
  styles/site.css         Your site's styles
  scripts/blocks.js        Starts the block loader
  blocks/                 Editable block source
  blocks.config.json      Site and build settings

3. Add an interactive block

Replace all of pages/index.html with the following. This restores the original greeting and adds a link and two questions:

---
title: Hello world | My first site
description: My first website built with Blocks UI.
---
<main id="main" class="hello-page">
  <div class="hero" data-loading="eager">
    <div><div>
      <h1>Hello, world!</h1>
      <p>My first website with Blocks UI.</p>
      <p><a href="/about/">About this site</a></p>
    </div></div>
  </div>
  <section aria-labelledby="questions">
    <h2 id="questions">A little more about this site</h2>
    <div class="accordion bordered" data-loading="eager">
      <div>
        <div>Do I need React?</div>
        <div>No. This page uses HTML, CSS, and JavaScript modules.</div>
      </div>
      <div>
        <div>Where can I host it?</div>
        <div>Anywhere that serves static files, including GitHub Pages.</div>
      </div>
    </div>
  </section>
</main>

Save and click Do I need React? The answer opens. Focus the question with Tab and press Enter or Space to toggle it with a keyboard.

The outer accordion class identifies the block; bordered selects its variant. Each outer row holds two cells: the question and its answer. The canonical decorator turns those rows into native details and summary elements.

You do not need to install or write accordion JavaScript. The starter already contains the canonical blocks, and scripts/blocks.js starts the loader. data-loading="eager" asks it to enhance this block immediately. Without JavaScript, the authored questions and answers remain readable.

The About link is not ready yet. Create its destination next.

4. Create another page

Create a new file named pages/about.html and paste this complete content:

---
title: About | My first site
description: What I learned while building my first Blocks UI site.
---
<main id="main" class="hello-page">
  <div>
    <h1>About this site</h1>
    <p>I built a real, two-page website with Blocks UI.</p>
    <p>The pages are HTML. The styles use shared tokens.
      An accordion adds interaction without a framework.</p>
    <a class="button" href="/">Back home</a>
  </div>
</main>

Now replace fragments/nav.html with:

<header class="hello-nav">
  <nav aria-label="Main navigation">
    <a href="{{ base }}">Home</a>
    <a href="{{ base }}about/">About this site</a>
  </nav>
</header>

Open http://127.0.0.1:3000/about/ (or the port you chose). Both links should work, including after a reload.

pages/about.html becomes /about/. This is a separate HTML page, not a client-side route. The layout and navigation are shared by both pages. {{ base }} keeps those navigation links correct when the site is published in a repository subfolder.

If you already know React, think of a block as a reusable UI unit, a layout as the shared document shell, and a fragment as shared markup. You author HTML instead of JSX; the browser handles navigation and interactive blocks enhance the existing DOM.

5. Make it yours

Add the following to the end of styles/site.css:

:root {
  --radius: 1rem;
}

The buttons and bordered accordion now have rounder corners. Shared CSS variables are the design tokens; you can customize the source without a theme provider. The foundation already follows the system's light/dark preference.

Change the greeting, page descriptions, and footer to make the site yours. Keep shared styles and scripts in the layout rather than repeating them in every page.

6. Build your website

In a second terminal, open the my-first-site folder and run:

npm run build

The output is ready to host:

dist/index.html
dist/about/index.html
dist/blocks/
dist/styles/
dist/runtime/
dist/scripts/
dist/sitemap.xml
dist/robots.txt
dist/404.html

Upload the contents of dist/, not the source folder, to a static host. Node.js is needed for development and building, not to serve the finished website. Do not double-click the output HTML: JavaScript modules need an HTTP server.

7. Publish on GitHub Pages

Create an empty GitHub repository named my-first-site. In its Settings > Pages, choose GitHub Actions as the source.

Replace blocks.config.json with this complete configuration for the tutorial website. Replace YOUR-USERNAME with your GitHub username:

{
  "base": "/",
  "site": {
    "title": "My first Blocks UI site",
    "description": "A small website made with HTML, CSS, and JavaScript.",
    "url": "https://YOUR-USERNAME.github.io"
  }
}

The site.url value gives generated canonical URLs and the sitemap the correct origin.

Create .github/workflows/pages.yml inside my-first-site, with this complete workflow:

name: Publish website
on:
  push:
    branches: [main]
  workflow_dispatch:
permissions:
  contents: read
  pages: write
  id-token: write
concurrency:
  group: pages
  cancel-in-progress: false
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 24
          cache: npm
      - run: npm ci
      - run: npm run build
        env:
          BLOCKS_BASE: /${{ github.event.repository.name }}/
      - uses: actions/configure-pages@v5
      - uses: actions/upload-pages-artifact@v3
        with:
          path: dist
  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Deploy
        id: deployment
        uses: actions/deploy-pages@v4

BLOCKS_BASE automatically uses the repository name, so production links become /my-first-site/about/. Your local development base stays /. This workflow targets a project repository, not a USERNAME.github.io repository or a custom domain.

Stop the development server before initializing Git. Run these commands inside my-first-site, replacing YOUR-USERNAME:

git init -b main
git add .
git commit -m "Create my first Blocks UI website"
git remote add origin https://github.com/YOUR-USERNAME/my-first-site.git
git push -u origin main

Commit package-lock.json, which npm install generated; the workflow needs it for npm ci. Do not commit node_modules/ or dist/; the starter's .gitignore excludes them.

When the Pages workflow succeeds, open https://YOUR-USERNAME.github.io/my-first-site/. Push later edits to main to rebuild and publish again.

If something goes wrong

  • Unknown template: hello-world: update your source checkout with git pull --ff-only, then retry from its parent folder.
  • Directory is not empty: choose a new project name. The CLI will not overwrite an existing website.
  • Missing module or package: run npm install in the generated website, not just npm ci in the library checkout.
  • An answer does not open: check for class="accordion", the two-cell row structure, and data-loading="eager". The browser's Network panel should show the block's CSS and JavaScript loading successfully.
  • A published page has broken links or missing styles: check BLOCKS_BASE and publish dist/. Do not hard-code localhost or the documentation site's /blocks-ui/ prefix.

Keep building

You now have a real two-page website. Add another page, try cards or tabs, or study the complete Offroute site.

For larger starting points, the CLI also offers saas, portfolio, blog, and documentation templates. See Building websites and Deployment for more.

Edit this page on GitHub

Search documentation

Search the docs, components, and blocks. Use Tab to select a result.