readysite / docs / tutorial.md
4.9 KB
tutorial.md

Building Your First Site

This tutorial walks you through creating a website using ReadySite's AI-native CMS.

Prerequisites

  • Go 1.24+ installed
  • Git

Step 1: Install ReadySite

# Clone the repository
git clone https://github.com/readysite/readysite.git
cd readysite

# Run the website CMS
go run ./website

Open http://localhost:5000 in your browser.

Step 2: Complete Setup Wizard

On first run, you'll see the setup wizard:

  1. Create Admin Account

    • Enter your email and password
    • This becomes your admin login
  2. Configure AI Provider

    • Select your AI provider (Anthropic, OpenAI, etc.)
    • Enter your API key
    • Choose a model
  3. Site Information

    • Set your site name
    • Add a site description

Click "Complete Setup" to finish.

Step 3: Create Your First Page

  1. Click Pages in the sidebar
  2. Click New Page
  3. Fill in the form:
    • Title: "About Us"
    • Slug: "about" (auto-generated from title)
    • Content: Add your HTML content
<div class="container mx-auto p-8">
    <h1 class="text-4xl font-bold mb-4">About Us</h1>
    <p class="text-lg">Welcome to our website!</p>
</div>
  1. Click Save

Your page is now available at /about.

Step 4: Create a Collection

Collections are like database tables for dynamic content.

  1. Click Collections in the sidebar
  2. Click New Collection
  3. Name it "Blog Posts"
  4. Add fields:
Field Type Required
title Text Yes
content Text No
published Boolean No
publishedAt Date No
  1. Click Save

Step 5: Add Documents

Documents are records in a collection.

  1. Select your "Blog Posts" collection

  2. Click New Document

  3. Fill in the fields:

    • title: "Hello World"
    • content: "This is my first post"
    • published: true
    • publishedAt: today's date
  4. Click Save

Step 6: Display Collection Data in Pages

Update your page HTML to display blog posts:

<div class="container mx-auto p-8">
    <h1 class="text-4xl font-bold mb-8">Blog</h1>

    {{range $post := documents "blog-posts"}}
    <article class="mb-8 p-6 bg-base-200 rounded-lg">
        <h2 class="text-2xl font-bold">{{$post.GetString "title"}}</h2>
        <p class="mt-2">{{$post.GetString "content"}}</p>
        {{with $date := $post.GetTime "publishedAt"}}
        <time class="text-sm text-base-content/60">{{$date.Format "Jan 2, 2006"}}</time>
        {{end}}
    </article>
    {{else}}
    <p class="text-base-content/60">No posts yet.</p>
    {{end}}
</div>

Available template functions:

  • documents "collection-name" - Get all documents
  • document "collection-name" "id" - Get single document
  • site_name - Site name
  • site_description - Site description

Step 7: Use AI Chat

The AI assistant can help you build and manage your site.

  1. Click the chat icon in the sidebar
  2. Try these prompts:

Create content:

Create a contact page with a form

Update existing content:

Update the About page to add our team members

Manage collections:

Add a new blog post about getting started

The AI will execute tools to create/update content, and you can undo any changes.

Step 8: Publish Your Site

Pages have a "Published" toggle:

  • Published: Visible to the public
  • Unpublished: Only visible in admin

Toggle the publish state in the page editor.

Step 9: Deploy to Production

  1. Set environment variables:
export AUTH_SECRET="your-secure-secret-here"
export ENV="production"
  1. Build and deploy:
go run ./cmd/launch --new website

This creates a server and deploys your website.

Next Steps

  • Endpoints: Create serverless Lua functions at /admin/endpoints
  • File uploads: Upload images and documents at /admin/files
  • Access control: Set permissions on content

Template Reference

Document Methods

{{$doc.GetString "field"}}     <!-- String value -->
{{$doc.GetInt "field"}}        <!-- Integer value -->
{{$doc.GetBool "field"}}       <!-- Boolean value -->
{{$doc.GetTime "field"}}       <!-- time.Time value -->
{{$doc.GetStrings "field"}}    <!-- []string value -->

Page Hierarchy

{{range $page := pages}}
    <a href="{{$page.Path}}">{{$page.Title}}</a>
{{end}}

{{range $child := page.Children}}
    <a href="{{$child.Path}}">{{$child.Title}}</a>
{{end}}

Conditional Content

{{if $doc.GetBool "featured"}}
    <span class="badge">Featured</span>
{{end}}

{{with $author := $doc.GetString "author"}}
    <span>By {{$author}}</span>
{{end}}

Troubleshooting

"Page not found" for published page

  • Check that the page is published (toggle on)
  • Verify the URL matches the page slug

AI chat not working

  • Verify your API key in Settings
  • Check the browser console for errors

Collection data not showing

  • Ensure the collection name matches exactly (use slugified name)
  • Check that documents exist in the collection
← Back