clubstudio / craft
Requires
- craftcms/ckeditor: ^5.6.1
- craftcms/cms: ^5.12.2
- nystudio107/craft-retour: ^5.0.12
- nystudio107/craft-seomatic: ^5.1.18
- nystudio107/craft-vite: ^5.0.0
- verbb/formie: ^4.1.0
- verbb/navigation: ^4.1.1
- vlucas/phpdotenv: ^5.4.0
Requires (Dev)
- craftcms/generator: ^2.0.0
- yiisoft/yii2-shell: ^2.0.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-30 11:21:27 UTC
README
Craft CMS Boilerplate
A scaffolding package to help you hit the ground running with your next Craft CMS project.
What's included?
- Craft CMS
- Tailwind CSS
- Vite
- A flexible, accessible content builder with responsive image transforms
- A sensible directory structure
- Commonly used plugins — CKEditor, Formie, Navigation, Retour and SEOmatic
Getting Started
Install or update DDEV (which requires Docker), then follow these steps:
- Create a project directory and move into it:
mkdir my-craft-project && cd my-craft-project - Create DDEV configuration files:
ddev config --project-type=craftcms --docroot=web - Scaffold the project from this starter project:
This replaces this README andddev composer create-project "clubstudio/craft"composer.jsonwith your project's own, fromREADME.md.defaultandcomposer.json.default, and removes the starter'sAGENTS.mdandCHANGELOG.md. - Finish setting up the project:
This restarts DDEV so it loads the config the starter ships inddev setup.ddev/(the Vite dev server port and the MCP server's keys), and installs npm dependencies. - Run Craft's installer, answering each prompt as it's asked:
ddev craft install - Run
ddev launchto view your site in the browser - Log in to the Craft control panel at
/admin(or runddev launch /admin) with the admin account you created during install
Next, feel free to read the official Craft installation documentation.
Developing
Start the Vite dev server, with hot reloading, and leave it running while you work:
ddev npm run dev
Pages render without styles unless it's running. To build optimised, cache-busted assets into web/dist/:
ddev npm run build
When you've finished working, run ddev stop to shut down the project containers and free up resources.
Your project's README lists the other DDEV commands you'll use, including ddev setup for teammates cloning the project.
Project Config
Craft's project config is the source of truth for your site's schema — fields, entry types, sections and settings. It's stored as version-controlled YAML in config/project/.
- After pulling changes from a teammate, run any pending migrations and sync your database with:
ddev craft up - In
dev,CRAFT_ALLOW_ADMIN_CHANGES=truelets you edit the schema from the control panel. Craft writes those edits back toconfig/project/, so commit the updated YAML alongside your code.
MCP
Craft's built-in MCP server lets AI assistants like Claude Code read and manage your content and schema. It's set up for local development out of the box:
- Enabled in project config. The authenticated server is turned on under Settings → MCP, at
/admin/mcp. The public server stays off. - Dev only.
config/app.web.phpswitches the server off unlessCRAFT_ENVIRONMENT=dev, so on staging and production its endpoints return a 404. - OAuth keys. The
.ddev/config.mcp.yamlhook generates signing keys instorage/the first time DDEV starts with Composer dependencies installed, andddev setupgenerates them if they're missing. The keys are git-ignored. To generate them by hand, runddev craft oauth/generate-keys. - Claude Code.
composer create-projectwrites a.mcp.jsonpointing at your DDEV site. Commit it so your team shares it. In Claude Code, run/mcp, choosecraft, sign in to Craft and approve the request. Access is read-only by default, and admins can grant full access.
Other MCP clients can connect to https://<project>.ddev.site/admin/mcp/auth. To skip OAuth for a local client, use stdio: ddev craft mcp/serve --user=<email> runs as that user.
Template System
This boilerplate uses a flexible content builder pattern with reusable components and macros.
Directory Structure
templates/
├── _layouts/ base (the HTML document), master (header, <main>, footer) and error
├── _partials/ Header, footer, skip link and the link for a menu item
├── _pages/ entry.twig, the template every section uses, includes the one for the entry's type
├── _content-blocks/ One template per content block; they read CMS content and pass it to components
│ └── index.twig Renders a list of blocks
├── _components/ Reusable UI; components take the values they show
│ └── layout/ Section, container, split and columns, which arrange what's embedded in them
├── _macros/ Class maps, aspect ratios, transform keys, SVG assets
├── _styleguide/ Each component with sample values, at /styleguide in dev mode
├── _dev/ Development helpers (the breakpoint helper)
├── _errors/ Error pages: 404, 503 and error for everything else
└── site.webmanifest.twig
Template Hierarchy
Templates follow an inheritance pattern:
- base.twig - HTML document structure, head tags, Vite script integration
- master.twig - Extends base, adds header/footer and
<main>landmark - Page templates - Specific page layouts that extend master
Sections with URLs use _pages/entry.twig as their template. It includes _pages/{entry-type-handle}.twig (kebab-cased), so each entry type has one page template: Home and Pages use the Builder entry type, rendered by _pages/builder.twig.
Error pages in _errors/ extend _layouts/error, which stands alone rather than extending base: it reads nothing from the database, so error pages still render when the database is the problem.
Content Blocks
Editors compose pages from content blocks, the entries in the Content Blocks field and the Matrix fields nested in it. Each level has its own Matrix field, shown here in brackets:
Builder entry (Home and Pages)
└── [Content Blocks]
├── Hero ───────────────────────────── [Content]
└── Section ────────────────────────── [Section Content]
├── Content Group, Content & Media,
│ CTA and FAQs ───────────────── [Content]
├── Columns ────────────────────── [Columns]
│ ├── Text Column ────────────── [Content]
│ └── Image, Video, Testimonial Entry, Statistic
└── Image, Video, Rich Text, Logos, Form, Divider
[Content]: Eyebrow, Heading, Paragraph, Links, Accordion, List, Testimonial Entry, Form, Icon,
Breadcrumb, Image, Image (Inline), Divider
The footer's Call to Action, in Site Settings, is a Content field too. A block type can be in more than one field (Image is in Section Content, Columns and Content), so _content-blocks/ has one template per block type, not a folder per field. A block that looks different in one place gets a context override instead (below).
_content-blocks/index.twig renders a list of blocks:
{% include '_content-blocks' with {
context: 'page',
blocks: entry.contentBlocks.all(),
} only %}
How it works:
- Iterates through content blocks
- Includes appropriate templates with context-aware fallbacks
- Supports nested blocks for complex layouts
Template Resolution Order:
_content-blocks/{context}/{block-type}.twig(context-specific override, for each context in turn)_content-blocks/{block-type}.twig(default)
Example contexts: page, hero, footer, columns/2, content-and-media
Image Transform System
Images use contextual transforms defined in config/custom.php for optimal responsive delivery:
Transform Key Pattern: Keys are built hierarchically as blocks nest:
section:full-bleed- Full bleed section (edge to edge)section:full-width- Full width section (inside the site's gutters)section:medium,section:narrow- Capped content widthssection:full-width:columns:12- Columns in a full width section, keyed by Column Layout (11,12,21,13,31or111); images are sized for the widest columnsection:full-width:content-and-media- Content & Media blocksection:full-width:faqs- FAQs block
A key that isn't in config/custom.php falls back to its nearest parent that is (section:narrow:my-block uses section:narrow), then to default.
Each sizes is written for the gutter, content widths and gaps the CSS uses, which are listed at the top of config/custom.php. If you change any of them in the CSS, update the sizes that use them.
Building Transform Keys:
{% import '_macros/transforms' as transforms %}
{% set transformKey = transforms.buildKey([transformKey, 'my-block']) %}
Adding New Transforms:
- Add configuration to
config/custom.php - Define
width,srcsetarray, andsizesstring - Match the hierarchical key pattern
Debug Mode: In development mode, HTML comments show the transform key used for each image, and the key it fell back to.
Content Width and Gutters
A Section's Content Width sets how wide its content is: Full bleed (edge to edge), Full width (inside the gutters, the default), Medium or Narrow. The gutter is one CSS variable, --gutter in src/css/site.css, used through the px-gutter class by sections, the header, footer and hero. The Medium and Narrow widths are --container-medium and --container-narrow in the same file, and the space between blocks in a Section is --block-gap, used through gap-block.
Components
Components in _components/ take the values they show, never CMS content, so they work anywhere: in blocks, page templates and the style guide. Each one follows the same contract:
- It starts with a header comment: its name and what it is, then its inputs, each with its default in brackets.
- It sets those defaults with
{% set data = { … }|merge(_context|filter(value => value is not null)) %}and reads its inputs fromdata. The filter means an input passed asnull, such as an empty field, gets the default rather than replacing it. classadds classes to the element its header names, as a string or an array, joined withclasses.combine().- Where its header lists
attributes, that adds HTML attributes to the element it names, merged into oneattr()call, so a class or type given there joins the component's own rather than repeating the attribute. - It's included with
only, so it sees nothing but its inputs.
Template Conventions
- Block templates receive
block,context,transformKeyandcontentWidthvariables. A block that renders blocks of its own passestransformKeyandcontentWidthon to them. transformKeyonly chooses image sizes. A block that lays itself out by its Section's Content Width readscontentWidth(full-bleed,full-width,mediumornarrow), never the key.- Use
block.fieldName.eagerly().one()or.all()for related content - Use
{{ 'Text'|t }}for all user-facing strings (translation support) - Include SVGs with
{{ svg('@svg/path.svg')|attr({...}) }} - Add JavaScript as a module in
src/js/modules/whose default export takes an element, and give the elements it works ondata-module="name".site.jsloads a module only on pages whose markup names it. - Keep CSRF tokens out of the page's shared markup, so pages can be cached whole (Blitz, a CDN). Formie forms add their own. In a hand-written form, use
{{ csrfInput({ async: true }) }}, which fetches the token when the page loads;->asyncCsrfInputs()inconfig/general.phpdoes that for every form, which then needs JavaScript to submit. In JavaScript, get it from/actions/users/session-info(withAccept: application/json), whose response includescsrfTokenValue.
Accessibility Standards
Templates aim for WCAG 2.2 AA:
- Semantic HTML with landmarks (
<header>,<main>,<footer>, and a labelled<nav>for each menu) - A skip-to-content link, and a focus indicator that shows on any background (
--color-focusand--color-focus-contrastinsite.css) aria-currenton the current page's links, and screen reader text on links that open in a new tab- Decorative images and icons hidden from screen readers:
alt=""on images,aria-hidden="true"on SVGs - A mobile menu that works without JavaScript, and animations that respect reduced motion
- Form labels and error messages, from Formie
Editors choose heading levels in the Heading block, so a page's heading order depends on its content: check that each page has one <h1> and no skipped levels.
Macros
Utility macros are available in _macros/:
Classes (_macros/classes.twig):
combine(base, extra)- Joins a component's classes with a caller'sclassinputpaddingTop(preference)/paddingBottom(preference)- Responsive section paddingcontentMaxWidth(preference)- The cap for Medium and Narrow content widthshorizontalAlignment(preference)- Horizontal alignment classesverticalAlignment(preference)- Flexbox vertical alignmentbackgroundColor(preference)- Background color utilitiestextAlignment(preference)- Text alignment classescolumnLayout(preference)- Grid column layouts
Media (_macros/media.twig):
aspectRatio(preference)- The class for an aspect ratio, or with'value'the ratio as a number. The one list of ratios; its keys match the Aspect Ratio field's options
Transforms (_macros/transforms.twig):
buildKey(segments)- Builds transform keys from array of segments
SVG (_macros/svg.twig):
asset(asset, attrs, namespace)- Inlines an uploaded SVG asset, cached so a remote volume isn't read on every request
Creating New Blocks
- Create a new entry type in the control panel, and add it to the Matrix field it belongs in (Content Blocks, Section Content, Content or Columns)
- Add a template in
templates/_content-blocks/{block-type-handle}.twig(kebab-cased:contentAndMediaiscontent-and-media.twig).indexcan't be a block type handle, becauseindex.twigrenders the blocks - Keep it to reading the block's fields and passing them to a component in
_components/, adding one if none fits - (Optional) Add a context-specific override in
_content-blocks/{context}/{block-type-handle}.twig - If the block contains images, add its transform key suffix with
transforms.buildKey()and its sizes toconfig/custom.php
Example block template:
{# Quote: a pull quote with who said it. #} {% include '_components/quote' with { quote: block.quote, person: block.person, } only %}
A block that renders blocks of its own passes transformKey and contentWidth on:
{% include '_content-blocks' with {
context: 'my-block',
blocks: block.content.eagerly().all(),
transformKey: transformKey,
contentWidth: contentWidth,
} only %}
About Craft CMS
Craft is a content-first CMS that aims to make life enjoyable for developers and content managers alike. It is optimized for bespoke web and application development, offering developers a clean slate to build out exactly what they want, rather than wrestling with a theme.
Learn more about Craft at craftcms.com.
Resources
- Documentation – Read the official docs.
- Guides – Follow along with the official guides.
- #craftcms – See the latest posts about Craft.
- Discord – Meet the community.
- Stack Exchange – Get help and help others.
- CraftQuest – Watch unlimited video lessons and courses.
- Craft CMS Newsletter – Stay in-the-know.