Task
Description |
|---|
Phase 1: Getting started and setup | Setup and workflow (Choose path A or path B) | Path A: GitHub Sync setup (Recommended) | Recommended workflow. Uses GitHub as the source of truth. Connect a GitHub repository, clone it, install dependencies, create a |
GitHub Sync workflow | Pull changes, work in editor/agent, commit/push, and allow synchronization. | ||
Path B: Manual CLI setup (Advanced) | Advanced workflow. Allows direct publishing without Github. Access site, add API client, store secret, select scopes, and save. Create project, select template and AI agent. Copy | ||
Manual CLI workflow | Pull latest changes, work locally, and push changes. | ||
Phase 2: Building with the agent | Local development | AI agent setup | Open the project in the AI coding agent. Seed the project by copying example directories. |
Local preview | Run | ||
Generation inputs (Choose one or more sources) | Input sources | Instruct the agent on which source is authoritative when combining multiple inputs. | |
Build from live URL | Optional input method for visual baselines. Provide public URL and run build/QA prompt. | ||
Build from Figma | Optional input method using design context. Use Figma MCP to provide design context and run build/QA prompt. | ||
Remote Configuration | Configure navigation | Enable Source MCP, get connection details, connect to AI agent, and request menu inspection. |
Proper setup prepares the local environment and the Acquia Source CMS site for site building. The following sections outline the prerequisites, explain how to select an appropriate workflow, and provide instructions for establishing the codebase using either GitHub synchronization or the manual Canvas CLI.
Proper site configuration ensures compatibility with generated Drupal Canvas assets. It is recommended to create the Acquia Source CMS site from the Blank template. To obtain a larger set of starter components, use the Default site template.
This setup utilizes GitHub to manage version control and automatically synchronize select site configuration with Source CMS. The recommended workflow connects the Source CMS site to a GitHub repository. After connecting a repository, Source CMS prepares the Drupal Canvas project structure in that repository and keeps generated Drupal Canvas assets synchronized with version control.
To configure the repository, do the following:
Run the following command in the local terminal to clone the connected repository:
git clone [email protected]:<username-or-org>/<repository>.gitRun the following commands to install dependencies:
cd <repository> npm installCreate a .env file with the following content:
CANVAS_SITE_URL=https://<your-source-site>.cms.acquia.site CANVAS_JSONAPI_PREFIX=apiRun the following command to authenticate with Source CMS:
npx canvas loginAfter configuring the repository, keep version control in sync by pushing local changes to GitHub rather than pushing directly to Source CMS.
To use GitHub as the source of truth for generated Drupal Canvas assets, do the following:
The manual synchronization workflow allows direct publishing of local codebase changes to Source CMS without relying on the build-in GitHub synchronization. Select this workflow to synchronize changes with Source CMS manually through Drupal Canvas CLI.
To create an API client for Drupal Canvas CLI authentication in Source CMS, do the following:
/admin/config/services/api-clients/..env.The system displays the Client Credentials settings menu.
canvas:.In your local terminal, to scaffold a new codebase, run the following command:
npx @drupal-canvas/create@latestacquia/nebula as the template.Run the following commands to open the generated project and copy the .env.example file to create a .env file:
cd <project-name>
cp .env.example .envSet the Source CMS URL and API client credentials in the .env file with the following configuration:
CANVAS_SITE_URL=https://<your-source-site>.cms.acquia.site
CANVAS_CLIENT_ID=<client-id>
CANVAS_CLIENT_SECRET=<client-secret>
CANVAS_JSONAPI_PREFIX=apiUse the Canvas CLI to manually push and pull assets when automated version control synchronization is not active.
Version control remains strongly recommended for this workflow, especially when multiple users work on the Drupal Canvas assets. The npx canvas pull command synchronizes Code Components. The command does not pull supporting imports unless they are also Code Components. Keep third-party dependencies, shared JavaScript modules, SVGs, images, and other supporting files in version control.
To synchronize Drupal Canvas assets between the local codebase and Source CMS with Drupal Canvas CLI, do the following:
Run the following command before starting work, because Source CMS can have newer changes:
Run npx canvas pull Run the following command to publish local changes to Source CMS:
npx canvas push AI coding agents utilize specific skills and the local codebase to generate and edit Drupal Canvas assets. Both setups yield a local codebase connected to Source CMS. Open the project in the AI coding agent. The codebase includes agent skills in .agents/skills/ to create and edit Code Components, pages, content templates, and global regions.
You can start from the examples, or you can ask the agent to generate new assets.
To seed the project with examples, copy the following directories:
examples/components/ to src/components/.examples/pages/ to pages/.examples/regions/ to regions/.The agent can add packages, shared code, SVGs, and other static assets from the local codebase. Use the Code Components imports and assets reference for supported import patterns. The repository also includes checks for the agent to run during development.
Drupal Canvas Workbench provides a local environment to review changes before synchronization with Source CMS. Use Workbench to preview Code Components, pages, global regions, and content templates before synchronizing changes to Source CMS. You can also ask the AI coding agent to use Workbench to verify its changes against the local preview.
To start Drupal Canvas Workbench from the local terminal, run the following command:
npm run devAI coding agents require design references or structural context to accurately generate Drupal Canvas assets.
Your AI coding agent can use one or more references as input, including:
When using multiple inputs, specify which source is authoritative if the references conflict. Use the following example prompt:
Build Drupal Canvas Code Components, page specs, and region specs using <figma-url>, <url>, and patterns from <path-to-codebase>. Treat Figma as the source of truth for layout. Run local visual QA in Workbench.Your AI coding agents can use a live website as a visual baseline to generate corresponding Drupal Canvas assets.
To build from a live website, do the following:
Enter the following instruction, replacing <url> with the public URL you want to use as a design reference:
Build Drupal Canvas Code Components, page specs, and region specs from <url>. Run local visual QA in Workbench.After you submit the instruction, the agent inspects the URL, creates local Drupal Canvas assets, and verifies the result in Workbench.
AI coding agents extract precise design contexts directly from Figma using the Figma MCP server. Figma MCP is useful when starting from a Figma file or URL. The server provides the agent with design context from Figma, such as frames, layers, and design tokens.
Use the following example prompt:
Build Drupal Canvas Code Components, page specs, and region specs from <figma-url>. Run local visual QA in WorkbenchTo manage site structure effectively, the AI coding agent modifies navigation menus directly on the remote Source CMS site. Source CMS provides an MCP server that the AI coding agent uses for menu and menu link work.
To configure and use the Source MCP for navigation menus, do the following:
/admin/config/services/mcp. Request the agent to inspect existing menus before making changes.
For example, use the following prompt:
Use Source MCP to add menu links for the new pagesIf this content did not answer your questions, try searching or contacting our support team for further assistance.
Local preview |
Run |
Generation inputs (Choose one or more sources) | Input sources | Instruct the agent on which source is authoritative when combining multiple inputs. |
Build from live URL | Optional input method for visual baselines. Provide public URL and run build/QA prompt. |
Build from Figma | Optional input method using design context. Use Figma MCP to provide design context and run build/QA prompt. |
Remote Configuration | Configure navigation | Enable Source MCP, get connection details, connect to AI agent, and request menu inspection. |
If this content did not answer your questions, try searching or contacting our support team for further assistance.