Skip to content

adrianmikula/AiWordpressGenerator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WP AI Builder

A local AI-powered WordPress site generator. Describe a business, get a fully structured 4-page WordPress site with Gutenberg-compatible block markup, published directly to a LocalWP instance — no cloud services, no API costs.

How it works

  1. You type a business description (e.g. "perth plumber")
  2. The app sends a prompt to a local Ollama LLM (Mistral)
  3. The LLM returns structured JSON content for 4 pages: Home, Services, About, Contact
  4. The content is converted to Gutenberg block HTML
  5. Optionally, the pages are pushed directly to a LocalWP WordPress site via the REST API

Requirements

  • Node.js v18+
  • Ollama running locally with the Mistral model
  • LocalWP (optional, for publishing to WordPress)
  • WP-CLI (optional, required if the app needs to run wp commands)

Prerequisites

WP-CLI (Windows)

WP-CLI has limited Windows support — the official docs note it's primarily built for Linux/macOS environments. Some commands may not work as expected natively on Windows.

If you see 'wp' is not recognized as an internal or external command, the recommended approach is to use LocalWP's built-in site shell, which bundles its own WP-CLI and PHP in a Linux-like environment:

  • In LocalWP, right-click your site → Open Site Shell
  • Run wp commands from there

This is the most reliable option on Windows. Native global installation is possible but not officially supported and may have edge cases:

  1. Download wp-cli.phar from https://wp-cli.org
  2. Make sure PHP is on your PATH
  3. Create a wp.bat wrapper (e.g. C:\tools\wp.bat):
    @ECHO OFF
    php "C:\tools\wp-cli.phar" %*

If you run into issues with WP-CLI on Windows, consider using WSL (Windows Subsystem for Linux) as an alternative.


Setup

1. Install Ollama and pull Mistral

Download Ollama from https://ollama.com, then:

ollama pull mistral

Keep Ollama running in the background while using the app.

2. Install dependencies

cd wp-ai-builder
npm install

3. Configure environment

Copy the example env file:

cp .env.local.example .env.local

If you're only generating content (not publishing), you can leave .env.local as-is.

To enable publishing to LocalWP, see the LocalWP setup section below.

4. Start the app

npm run dev

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


Usage

  1. Type a business description in the input field, e.g. perth electrician
  2. Click "Generate Site"
  3. Wait for the LLM to respond — this takes 15–60 seconds depending on your hardware
  4. Review the generated Gutenberg HTML for each page
  5. Click "Publish to LocalWP" to push the pages directly to your local WordPress site

LocalWP Setup (for publishing)

1. Create a site in LocalWP

Download LocalWP from https://localwp.com and create a new WordPress site. Note the local URL shown in the app (e.g. http://mysite.local).

2. Generate an Application Password

  • Open WP Admin for your LocalWP site
  • Go to Users → Your Profile
  • Scroll to "Application Passwords"
  • Enter a name (e.g. wp-ai-builder) and click "Add New"
  • Copy the generated password

3. Update .env.local

WP_URL=http://mysite.local
WP_USER=admin
WP_APP_PASSWORD=xxxx xxxx xxxx xxxx xxxx xxxx

Restart the dev server after saving. The "Publish to LocalWP" button will now push all four pages to your WordPress site. Re-running will update existing pages rather than create duplicates.


Running tests

npm test

Tests validate that the renderer produces correct Gutenberg block structure for all page types.


Project structure

wp-ai-builder/
├── app/
│   ├── page.js                  # Main UI
│   ├── layout.js
│   └── api/
│       ├── generate/route.js    # LLM generation pipeline
│       └── publish/route.js     # WordPress publish endpoint
├── lib/
│   ├── prompt.js                # Builds the LLM prompt
│   ├── llm.js                   # Ollama API client
│   ├── renderer.js              # JSON → Gutenberg HTML
│   └── wordpress.js             # WP REST API client
├── tests/
│   └── renderer.test.js
└── .env.local.example

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors