Working with Files
Create pages, components, and blog posts. Understand the project structure and manage your files.
Working with Files
This guide covers creating and managing files in your PhantomStudio project, including pages, components, layouts, and blog posts. The File Tree, where you manage files directly, is in Code mode (switch in the header).
Project Structure
Every PhantomStudio project follows the Astro folder structure:
src/
components/ # Reusable UI components
layouts/ # Page layouts (header, footer, etc.)
media/ # Images (Astro-optimized)
pages/ # Site pages (URL = file path)
blog/ # Blog posts
styles/ # CSS files
data/ # JSON data files
public/ # Static files (favicon, etc.)
Key Folders
| Folder | Purpose |
|---|---|
src/pages/ | Each file becomes a page. about.astro = /about |
src/pages/blog/ | Blog posts in MDX format |
src/components/ | Reusable components to import in pages |
src/layouts/ | Page templates with header/footer |
src/media/ | Images with automatic optimization |
public/ | Files served as-is (favicon, robots.txt) |
Creating Pages
Creating a New Page
In Design mode, open the page switcher at the top of the Builder and choose New page.
In Code mode, use the File Tree:
- Click the New Page button in the File Tree header toolbar
- Or click the + button that appears next to the
src/pagesfolder when you hover over it
Create Page Modal
The Create Page modal lets you configure your new page.
Start from Template
| Template | Description |
|---|---|
| Blank Page | Just the layout, no components |
| 404 Error Page | Custom "page not found" page |
Browse page templates opens the Templates tab of the Component Library, with ready-made pages (for example Landing Page, About Us, Services, Pricing, Contact and FAQ) built from sections.
File Format
Choose between:
- .astro - Full control with components and logic
- .mdx - Markdown with component support (great for content-heavy pages)
Layout
Pick one of your project's layouts (from src/layouts/), or Blank (no layout).
Rendering
Choose Static (built when you publish), Dynamic (built on every visit) or Dynamic, cached (built on demand, reused for a while). See Rendering.
Contact Form Backend
Contact pages and contact sections send their submissions wherever Forms settings (Site ▾ › Forms settings, or ⌘K › Forms settings) points. The choice is saved in src/config/forms.json and applies to every form on the site:
- Formspree - Enter your form ID
- Web3Forms - Enter your access key
- Custom endpoint - Enter the full URL your provider gives you for the form, such as
https://submit-form.com/your-form-idfor Formspark. Works with any service that accepts a form POST - WordPress - Delivered by
wp_mailthrough the PhantomWP Connect plugin (needs a connected WordPress site)
src/lib/forms.ts reads that file (as @/config/forms.json, since @/ points at src/) and is rewritten when you save Forms settings, so don't put custom code in it. See Forms for details.
Creating Pages in Subfolders
To create nested URLs like /services/web-design:
- Right-click the parent folder (e.g.,
src/pages/services) - Select New Page
- The page will be created in that folder

Page File Names and URLs
File names become URLs:
| File Path | URL |
|---|---|
src/pages/index.astro | / |
src/pages/about.astro | /about |
src/pages/services/design.astro | /services/design |
src/pages/blog/my-post.mdx | /blog/my-post |
Creating Components
Components are reusable pieces of UI. Create them in src/components/.
Creating a New Component
In Design mode, choose New component in the Builder's page switcher.
In Code mode:
- Click the New Component button in the File Tree header toolbar
- Or click the + button that appears next to
src/componentswhen you hover over it
Via Context Menu
- Right-click
src/components(or any subfolder) - Select New Component
Create Component Modal
The Create Component modal lets you configure your new component:

Component Name
Enter a name for your component. It will be converted to PascalCase automatically (e.g., "my card" becomes "MyCard").
Component Templates
Choose a starting template:
| Template | Description |
|---|---|
| Simple Component | Basic component with no props |
| Component with Props | Customizable props interface |
| Card Component | Pre-built card template |
| Button Component | Pre-built button template |
| Hero Section | Pre-built hero section |
For "Component with Props", you can define custom props with names, types (string, number, boolean), and default values.
Component File Structure
A basic component looks like this:
---
// Props interface
interface Props {
title: string;
description?: string;
}
const { title, description } = Astro.props;
---
<div class="card">
<h3>{title}</h3>
{description && <p>{description}</p>}
</div>Using Components
Import and use components in your pages:
---
import Card from '../components/Card.astro';
---
<Card title="My Card" description="Card content here" />Extracting Components
Turn any part of a page into a reusable component.
From the Builder
- Right-click an element in the Builder (or select it and press ⌘K)
- Choose Make a component…
- Check the suggested name and the props it gets, then confirm
- The code is moved to a new file and replaced with a component tag
If the element has look-alikes next to it (other cards in the same grid, for example), Make a component… turns them all into one component, and the parts that differ become props.
What Happens
When you extract a component:
- The selected HTML/JSX is copied to a new file
- The file is created in
src/components/ - The original code is replaced with
<ComponentName /> - The import is added to the page automatically
Before:
<section class="hero">
<h1>Welcome</h1>
<p>Hero description</p>
</section>After:
---
import Hero from '../components/Hero.astro';
---
<Hero />Creating Blog Posts
Blog posts are created in src/pages/blog/ as MDX files.
Creating a New Blog Post
- Click the + button next to
src/pages/blog - Or right-click
src/pages/blogand select New Blog Post
Blog Post Structure
Blog posts use MDX (Markdown with components):
---
title: "My Blog Post"
description: "A short description"
pubDate: 2024-01-15
author: "Your Name"
tags: ["tutorial", "astro"]
---
# Introduction
Write your content in Markdown...
## Using Components
You can import and use components:
import Card from '../../components/Card.astro';
<Card title="Example" />Blog Post Frontmatter
Common frontmatter fields:
| Field | Description |
|---|---|
title | Post title (required) |
description | Short summary for SEO |
pubDate | Publication date |
author | Author name |
tags | Array of tags |
image | Featured image path |
draft | Set to true to hide from listing |
Creating Layouts
Layouts wrap your pages with common elements like headers and footers.
Via Context Menu
- Right-click
src/layouts - Select New Layout
- Enter a name (e.g., "BlogLayout")
Layout Structure
---
interface Props {
title: string;
description?: string;
}
const { title, description } = Astro.props;
---
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width" />
<title>{title}</title>
<meta name="description" content={description} />
</head>
<body>
<header>
<!-- Navigation -->
</header>
<slot />
<footer>
<!-- Footer content -->
</footer>
</body>
</html>Using Layouts
Wrap your pages with a layout:
---
import BaseLayout from '../layouts/BaseLayout.astro';
---
<BaseLayout title="My Page">
<main>
<!-- Page content goes in the slot -->
</main>
</BaseLayout>Managing Files
Renaming Files
- Right-click the file
- Select Rename
- Enter the new name
- Press Enter
Or click the pencil icon that appears on hover.

When you rename components or layouts, PhantomStudio automatically updates all import statements in files that reference them.
Duplicating Files
- Right-click the file
- Select Duplicate
- Enter a new name
- Click Duplicate
Moving Files
Drag and drop files between folders:
- Click and hold a file
- Drag to the target folder
- Release to move
Files can only move within their section (pages stay in pages, components in components). When you move components or layouts, all import paths are updated automatically.
Deleting Files
- Right-click the file or folder
- Select Delete
- Confirm the deletion
Creating Folders
- Right-click the parent folder
- Select New Folder
- Enter a name
- Press Enter
File Search
Use the search bar at the top of the File Tree:
- Click the search icon or press
/ - Type part of the filename
- Results filter in real-time

Quick Reference
| Action | How To |
|---|---|
| New Page | Builder page switcher > New page, + button on src/pages, or right-click > New Page |
| New Component | Builder page switcher > New component, + button on src/components, or right-click > New Component |
| New Blog Post | + button on src/pages/blog or right-click > New Blog Post |
| New Layout | Right-click src/layouts > New Layout |
| Make a Component | Right-click an element in the Builder > Make a component… |
| Rename | Right-click > Rename or click pencil icon |
| Duplicate | Right-click > Duplicate |
| Delete | Right-click > Delete |
| Move | Drag and drop to target folder |
| Search | Press / or click search icon |
Next Steps
- Design mode - Edit pages and components visually in the Builder
- Component Library - Browse pre-built components
- Media Manager - Add images to your pages