Manage your Astrolock site directly from Visual Studio Code
Tip
The VS Code extension makes Astrolock easier to use - manage your site with right-click menus instead of memorizing terminal commands.
What is the VS Code Extension?
The Astrolock VS Code extension adds right-click menu options to manage your site directly from the editor. No need to switch to the terminal or remember command syntax.
What you can do:
- Create new collections with guided wizards
- Add content to existing collections
- Start/stop the development server
- Run builds and deployments
- All from right-click context menus
Installation
Prerequisites
You need:
- Visual Studio Code - Download from code.visualstudio.com
- Astrolock installed - See Installation Guide
Install the Extension
- Open VS Code
- Open the Extensions sidebar (
Cmd+Shift+Xon Mac,Ctrl+Shift+Xon Windows/Linux) - Search for “Astrolock”
- Click “Install”
If you have a .vsix file:
- Open VS Code
- Open Extensions sidebar
- Click the
...menu at the top - Select “Install from VSIX…”
- Choose the
.vsixfile
Opening Your Site in VS Code
Multi-Folder Workspaces
If you manage multiple Astrolock sites, use a multi-folder workspace:
File → Add Folder to Workspace…
Add each site directory. The extension will detect all Astrolock sites in your workspace.
Info
The extension automatically detects which site you’re working with based on which folder you right-click in.
Single Site
Just open your site directory:
File → Open Folder…
Select your Astrolock site root directory (the one containing .astrolock/).
Creating Collections
Using the Context Menu
The easiest way to create a collection:
- In the Explorer sidebar, find your site’s
.astrolockfolder - Right-click on the
.astrolockfolder - Select “Astrolock: Create New Collection”
The wizard will ask:
Collection name (e.g., "mixes", "photos"): photos
Display name (shown in menus): Photo Gallery
Content type:
› Text - Blog posts and articles
Audio - Music, podcasts, mixes
Images - Photos and galleries
Video - Tutorials, vlogs
File extension (e.g., jpg, mp3): jpgClick through the prompts to create your collection.
What Gets Created
When you create a collection, Astrolock automatically:
- Creates the directory structure -
content/[collection-name]/ - Registers it in
.astrolock/astrolock.yaml - Creates an index file -
content/[collection-name]/-index.md - Creates a sample file -
content/[collection-name]/sample-[collection-name].md
The sample file shows you exactly how to structure your content.
Multi-Folder Workspaces
Warning
Important: In multi-folder workspaces, right-click on the specific site’s
.astrolock folder to create the collection in that site.
Example workspace structure:
Workspace
├── my-personal-site/
│ └── .astrolock/ ← Right-click here for personal site
└── my-business-site/
└── .astrolock/ ← Right-click here for business site
Creating Content
Using the Context Menu
To add content to a collection:
- In the Explorer, navigate to
content/[collection-name]/ - Right-click on the collection folder
- Select “Astrolock: Create New Content”
Content title: Summer Vacation Photos
The content file will be created at:
content/photos/summer-vacation-photos.md
Create this content? [Yes]The file opens automatically in the editor, ready to edit.
Quick Edit Workflow
- Right-click collection folder → Create content
- File opens with template frontmatter
- Edit the frontmatter and content
- Add your media file to
public/[media-type]/content/[collection]/ - Save and preview in browser
Development Server
Starting the Server
Right-click anywhere in your site and select:
“Astrolock: Start Development Server (write)”
This runs astrolock write and opens a terminal showing the build progress.
Info
The server starts on http://localhost:4321 by default. Your browser won’t
open automatically - you need to open it manually.
Stopping the Server
In the terminal running astrolock write, click the trash icon or press Ctrl+C.
Status Bar
When a server is running, you’ll see an indicator in the VS Code status bar (bottom of the window):
⚡ Astrolock: Running
Click it to see quick actions like stopping the server or opening the browser.
Building Your Site
Production Build
Right-click anywhere and select:
“Astrolock: Build Site (build)”
This creates the production-ready dist/ folder.
Build for Specific Target
If you have multiple deployment targets (staging, production):
“Astrolock: Build for Target”
Choose which target from the list.
Configuration
Extension Settings
Open VS Code Settings (Cmd+, or Ctrl+,) and search for “Astrolock” to see available options:
- Astrolock: CLI Path - Custom path to astrolock CLI (if not in PATH)
- Astrolock: Terminal Name - Name for integrated terminal (default: “Astrolock”)
- Astrolock: Auto-detect Sites - Automatically detect Astrolock sites in workspace
Keyboard Shortcuts
You can add custom keyboard shortcuts for common actions:
Code → Preferences → Keyboard Shortcuts (or Cmd+K Cmd+S)
Search for “Astrolock” to see all available commands.
Add these to your keybindings.json:
[
{
"key": "cmd+shift+a w",
"command": "astrolock.write",
"when": "astrolock.siteDetected"
},
{
"key": "cmd+shift+a b",
"command": "astrolock.build",
"when": "astrolock.siteDetected"
},
{
"key": "cmd+shift+a c",
"command": "astrolock.collection.add",
"when": "astrolock.siteDetected"
}
]Working with Multiple Sites
The extension fully supports multi-folder workspaces:
How It Works
- The extension detects all folders containing
.astrolock/astrolock.yaml - Context menu actions use the folder you right-clicked on
- Each site maintains its own terminal, status, and configuration
Best Practices
Create a workspace file:
File → Save Workspace As…
Save as my-sites.code-workspace. Next time, open this workspace file to load all your sites at once.
Organize by site:
├── personal-blog/
│ ├── .astrolock/
│ └── content/
├── business-site/
│ ├── .astrolock/
│ └── content/
└── client-portfolio/
├── .astrolock/
└── content/
Each site is independent. Right-click on the specific site to work with it.
Troubleshooting
Check that:
.astrolock/astrolock.yamlexists in your site root- The folder is added to your VS Code workspace
- Reload VS Code window:
Cmd+Shift+P→ “Reload Window”
Try:
- Make sure you’re right-clicking on a folder (not a file)
- Check that the extension is enabled: Extensions sidebar → Astrolock → Enabled
- Reload VS Code window
Common causes:
- Astrolock not in PATH - Set custom CLI path in extension settings
- Not in site directory - Make sure you opened the correct folder
- Dependencies missing - Run
yarn installornpm installin your site
View error details:
View → Output → Select “Astrolock” from dropdown
The extension uses the folder you right-clicked on. Make sure you’re right-clicking on the correct site’s folders, not a parent directory.
Workaround:
Close the workspace, open just the single site you want to work on.
Tips for Non-Technical Users
You Don’t Need to Use the Terminal
Everything you need for daily content management can be done with right-click menus:
- Creating collections → Right-click
.astrolock/ - Adding content → Right-click collection folder
- Starting preview → Right-click anywhere → “Start Development Server”
Finding Your Collections
All your collections are in the content/ folder. Each subfolder is a collection:
content/
├── blog/ ← Right-click here to add blog posts
├── photos/ ← Right-click here to add photos
└── mixes/ ← Right-click here to add mixes
Editing Content
Just click any .md file in your collections to edit it. The top section (between ---) is metadata, everything below is your content.
Adding Media Files
When you create media content (audio, images, video), you need to add the actual media file:
- Find the folder:
public/[audio|images|video]/content/[collection-name]/ - Copy your media file there
- Name it to match your content file name
Example:
- Content file:
content/photos/vacation.md - Image file:
public/images/content/photos/vacation.jpg
Next Steps
Tip
You now know how to use the VS Code extension! Try creating a collection and adding some content using the right-click menus.
Continue learning:
- Adding Content - How to write and format your content
- Step 2: Advanced Features - Collection customization and features
- Site Structure - Understanding your project layout
Common workflows:
1. Right-click .astrolock/ → Create Collection
2. Right-click collection/ → Create Content
3. Edit the .md file that opens
4. Add media file to public/ folder
5. Right-click → Start Development Server
6. Open http://localhost:4321 in browser