AI-Assisted Design: Building Templates with a Co-Pilot
So, you want to build a custom template for StaticForge, but you don't want to write every single <div> and CSS class by hand.
Good news: StaticForge speaks the same language as your AI assistant. Because we use standard, boring technologies—PHP, Twig, and raw CSS—tools like GitHub Copilot and ChatGPT are surprisingly good at generating high-quality templates for us.
This guide isn't just a tutorial; it's a "cheat code" for building templates fast.
The "Copycat" Strategy
The biggest mistake people make with AI is asking it to "make a website." That's too vague. The AI will hallucinate a bunch of complex frameworks you don't need.
The secret is the Reference Implementation Strategy.
Instead of teaching the AI how StaticForge works from scratch, you simply point it to our "Gold Standard" template (staticforce) and say:
"See this? Do it exactly like that, but make it look like [Your Vision]."
The Workflow: From Zero to Hero
Here is the exact workflow we use to build templates in minutes, not days.
Step 1: The Briefing (Set the Context)
First, you need to orient the AI. Tell it what tools we are using so it doesn't try to give you React or Vue code.
The Prompt:
"I am building a new template for a static site generator. We are using Twig for templating and Raw CSS (no frameworks). I want to create a template named 'my-new-template'."
Step 2: The Blueprint (Grounding)
This is the most critical step. You must force the AI to look at the existing code structure.
The Prompt:
"Before writing any code, I want you to examine the
templates/staticforcedirectory. This is the reference implementation.Study how
base.html.twigsets up the HTML shell. Note howstandard_page.html.twigextends it. Look at how the assets are linked using{{ site_base_url }}.Use this structure as the blueprint for my new template."
Step 3: The Vision (Style)
Now that the AI knows how to code it, tell it what to design. Be descriptive.
The Prompt:
"I want the visual style to be Cyberpunk Minimalist.
- Colors: Dark background (#0a0a0a), Neon Green accents.
- Layout: Single column, very wide margins.
- Typography: Monospace fonts for everything.
- Constraint: Do NOT use Bootstrap or Tailwind. Write plain, efficient CSS using Grid and Flexbox."
Step 4: The Construction (One Brick at a Time)
Don't ask for the whole site at once. The AI will get overwhelmed and give you trash. Build it piece by piece.
Phase 1: The Skeleton (base.html.twig)
This is your master template. Get this right first.
"Start by creating the
base.html.twig. It needs:
- The HTML5 boilerplate.
- A sticky navigation bar.
- A footer with copyright info using
{{ site_name }} {{ "now"|date("Y") }}.- The
{% block body %}where content will go.- Use
{{ styles|raw }}in the head and{{ scripts|raw }}in the footer."
Phase 2: The Homepage (index.html.twig)
"Now create
index.html.twig. It should extendbase.html.twig. Give me a big Hero section with the{{ site_tagline }}and a 'Get Started' button."
Phase 3: The Content (standard_page.html.twig)
"Create
standard_page.html.twigfor my blog posts. It should extendbase.html.twig. Keep it simple: just a title (<h1>) and the content block."
Pro Tips for Smooth Sailing
- The "No Framework" Rule: AI loves Tailwind and Bootstrap. If you don't want a massive dependency chain, explicitly tell it: "Write raw CSS only. Do not use classes I haven't defined."
-
Asset Paths: AI often forgets our specific variable names. If links break, remind it:
"Use
{{ site_base_url }}for all links and images." - Magic Variables: Remind it that
{{ styles }}and{{ scripts }}are handled by the Asset Manager, so it doesn't need to manually link CSS files. - Mobile First: Remind it to make things responsive. "Make sure the nav bar turns into a hamburger menu on mobile."
By following this script, you act as the Architect, and the AI acts as the Bricklayer. You provide the vision and the blueprints; it does the heavy lifting.