Skip to content

Getting started

To get started with our child-theme, follow these instructions to quickly set up and utilize the theme’s capabilities.

The theme is a child theme of Blocksy. It uses Vite to bundle the assets, Blade for templating and Composer for the PHP dependencies.

It is already part of our default install on default.best4u.dev, which is the starting point for every new project — so in most cases the theme is simply there and you can skip straight to Setup. If you do have to add it to an existing site manually, place it in wp-content/themes as blocksy-child.

  • Node.js — the version in the theme’s .nvmrc (currently v26.4.0). With nvm installed, run nvm use in the theme directory to switch to it.
  • A package manager — npm (ships with Node.js) or pnpm.
  • Composer
  • PHP 8.2 or higher
  • The Blocksy parent theme, installed and present in wp-content/themes/blocksy.

Go to the theme directory and run these three commands. The order matters — see the note below.

Terminal window
composer install # Installs the PHP dependencies
npm install # Installs the node dependencies
npm run prod # Builds the assets (CSS, JS, images)

When you want to start developing, just run the dev script. Vite will launch the development server on https://localhost:3334 and the theme will automatically include the files from the development server instead of the built assets.

Terminal window
npm run dev

Prefix these with npm run (or pnpm).

Script What it does
dev Starts the Vite development server on https://localhost:3334.
prod Bundles/compiles the code and assets into assets/public/.
prod:watch Same as prod, but rebuilds on every change.
lint Read-only check: Biome CI (JS/TS/JSON formatting + linting) and Prettier for SCSS.
format Fix mode: applies Biome formatting, lint fixes and import sorting, plus Prettier for SCSS.
typecheck Runs TypeScript type checking (tsc --noEmit).

Prefix these with composer.

Script What it does
translate Generates the translation file for the theme (wp i18n make-pot ., requires WP-CLI).
format Formats the PHP codebase with Mago.
format:check Checks the PHP formatting with Mago without writing changes.

Below is an overview of the key folders and files in the theme. While the theme contains additional files and directories, the ones listed here are the most relevant for development. It is recommended to modify only these unless you are certain about changes to other parts of the theme.

  • Directoryapp/ PHP classes, PSR-4 autoloaded as Best4u\BlocksyChild\
    • App.php
    • Blade.php
    • Environment.php
    • Templates.php
    • Vite.php
    • helpers.php
  • Directoryacf-json/ ACF Local JSON field groups
  • Directoryassets
    • Directorysrc
      • Directorycss
        • Directoryabstracts/
        • Directorybase/
        • Directorycomponents/
        • Directorylayout/
        • Directorypages/
        • Directoryvendors/
        • backend.scss
        • frontend.scss
      • Directoryimages/
      • Directoryjs
        • backend.js
        • frontend.js
        • helpers.ts
    • Directorysvg/ used by the svg() helper and @svg directive
    • Directorypublic/ generated build output, gitignored
  • Directoryblocks/ custom blocks (ACF/LazyBlocks/block.json)
  • Directoryinc
    • enqueue.php
    • generate-blocks.php
    • hooks.php
    • shortcodes.php
  • Directorypatterns/ block patterns
  • Directorytemplates/ per-post-type block templates
  • Directoryviews/ Blade templates
  • Directoryviews-cache/ generated compiled Blade views, gitignored
  • style.css
  • functions.php
  • composer.json
  • package.json
  • vite.config.js
  • biome.json
  • mago.toml
  • tsconfig.json
  • .nvmrc

Contains the theme’s PHP classes, autoloaded through Composer under the Best4u\BlocksyChild\ namespace. The wiring lives in App.php, which boots the Theme, Vite, Blade, Patterns and Templates classes, registers i18n, and then loads inc/ and blocks/.

functions.php is a bootstrap file only — don’t edit it, and don’t put CSS in style.css.

All files that do not start with an _ from this directory will automatically be loaded by the theme, including subdirectories. This is where you should put all your custom PHP code. No namespace or class is needed here; plain procedural PHP is fine.

It’s preferable to use a clear structure inside this folder. For example, when using different custom post types don’t use just one file, but structure it like this;

  • Directoryinc
    • Directoryproject
      • post-type.php
      • archive.php
      • single.php
    • Directoryproduct
      • post-type.php
      • archive.php
      • single.php

Use this folder for custom blocks. Any subdirectory containing a block.json is registered automatically with register_block_type(), recursively — this is what ACF blocks use. For those, a view.scss (frontend) or editor.scss (editor) in the block folder is glob-imported into the theme’s bundles by frontend.scss / backend.scss, so it does go through Vite and Sass.

For LazyBlocks Pro, set the output method of the block to Theme Template. After choosing this option it tells you exactly what folder to create inside the blocks folder — the block slug with the / replaced by a -, so lazyblock/hero becomes blocks/lazyblock-hero/.

Inside that folder LazyBlocks picks up a fixed set of filenames on its own:

  • Directoryblocks
    • Directorylazyblock-hero
      • block.php the template, used on the frontend and in the editor
      • editor.php optional — overrides block.php when rendering in the editor
      • block.css frontend styles
      • editor.css optional — styles loaded in the editor only
      • view.js optional — frontend script, loaded in the footer

Only block.php is required; the rest are optional and are simply skipped when the file isn’t there.

Use this folder for creating patterns in the child-theme to be used in Gutenberg. Just add a .php file with the pattern name and inside this file add the following comment

/**
* Title: Name of the pattern
* Slug: best4u/name-of-the-pattern
* Post Types: page, post
* Categories: best4u
*/

Holds per-post-type block templates. They are synced to a post-type-templates custom post type so editors can maintain them in the block editor, and the content is written back to <slug>.html in this folder.

Contains the Blade templates, compiled to views-cache/. Render them with the global view() helper. See Blade for the details.

Formatting is enforced by tooling, not by hand:

  • PHP — Mago (mago.toml, PSR-12 preset, 4 spaces). Run composer format.
  • JS, TS, JSON — Biome (biome.json): tabs, single quotes, no semicolons, line width 120.
  • SCSS — Prettier (.prettierrc.json), because Biome doesn’t support SCSS yet. The lint and format scripts run both tools back to back.

See IDE for the recommended extensions that hook these up in your editor.