clubstudioltd / 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
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 with one for your project, fromddev composer create-project "clubstudio/craft"README.md.default, and removes the starter's ownAGENTS.md. - 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
After setting up Craft, you're almost ready to start building! This starter ships a .ddev/config.vite.yaml config that exposes the Vite dev server port (5173), so there's no DDEV configuration to edit by hand.
Apply the shipped config and pull in frontend dependencies:
ddev restart
ddev npm install
Once the dependencies have been installed, you can compile assets and start a watcher (with hot-module reloading) using:
ddev npm run dev
Leave this running while you work. When you're ready to generate optimised, production-ready assets, run:
ddev npm run build
This writes hashed, cache-busted files to web/dist/.
That's it! Happy coding! 🎉
When you've finished working, run ddev stop to shut down the project containers and free up resources.
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, sync your database with:
ddev craft project-config/apply - 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 (theddev restartstep above). 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 HTML layouts
├── _partials/ Layout partials (header, footer, skip-link)
├── _components/ Reusable UI components; they take the values they show
│ └── cards/ One card per kind (content)
├── _builder/ Reads CMS content and passes it to components
│ ├── blocks/ One template per content block
│ ├── cards/ Reads an entry for its card (default.twig, or one per entry type)
│ ├── builder.twig Block renderer
│ ├── section.twig Section wrapper
│ └── container.twig Container wrapper
├── _pages/ Page-specific templates
├── _macros/ Twig macros for utilities
├── _dev/ Development utilities (breakpoint helper)
├── _critical-css/ Critical (inline) CSS partials
└── _errors/ Error page templates
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
Content Builder Pattern
The builder system allows content editors to compose pages using reusable blocks:
{% include '_builder/builder' 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:
_builder/blocks/{context}/{block-type}.twig(context-specific override, for each context in turn)_builder/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:2- 2-column layout in a full width sectionsection:full-width:content-and-media- Content & Media block
A key that isn't in config/custom.php falls back to its nearest parent that is (section:narrow:columns:2 uses section:narrow), then to default.
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.
Template Conventions
- Block templates receive
block,contextandtransformKeyvariables - 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({...}) }}
Accessibility Standards
All templates follow WCAG 2.1 AA standards:
- Proper semantic HTML with landmarks (
<main>,<header>,<footer>,<nav>) - Skip-to-content link for keyboard navigation
- ARIA attributes where appropriate (
aria-label,aria-current,aria-hidden) - Proper heading hierarchy
- Decorative images/icons marked with
aria-hidden="true" - Form labels and error messages
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 classesfontSize(preference)- Font size classesaspectRatio(preference)- Aspect ratio for mediacolumnLayout(preference)- Grid column layoutssectionTextContainer(preference)- Gutter for text beside full bleed media
Transforms (_macros/transforms.twig):
buildKey(segments)- Builds transform keys from array of segments
Creating New Blocks
- Create a new entry type in Craft CMS Control Panel
- Add a template in
templates/_builder/blocks/{block-name}.twig - (Optional) Add context-specific override in
_builder/blocks/{context}/{block-name}.twig - If the block contains images, add transform configuration in
config/custom.php
Example block template:
{# My Block - Description of what this block does #} {% set myData = block.myField.eagerly().all() %} <div class="my-block"> {# Block content #} </div>
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.