al.ncvp.me

using local WordPress site for all content

Create astro-local day 2 details


Another site sourced from a WordPress site like astro-wpress.

This time from localhost/wp/wp

See also

Contents

GitHub

Not needed. Normal Cloudflare deployment doesn't work with local WP.

Top

Local WP content sourcing

You can't use the normal Cloudflare build mechanism, but have to build locally and upload /dist

Install Cloudflare CLI tool (Wrangler)

% npm install -D wrangler

Connect to Cloudflare account

% npx wrangler login

Build Astro site locally

% npm run build

Upload complete site to Cloudflare

% npx wrangler pages deploy dist

Adding this to package.json

"deploy": "npm run build && wrangler pages deploy dist",

allows

% npm run deploy # Build and deploy in one command

Top

Setup

Copy /tsconfig.json from astro-wpress

Add

site: "https://al.ncvp.me",

devToolbar: { enabled: false },

to astro.config.mjs. Rest of file slightly different with MDX stuff

Create a 70x70 logo, and put separately named copies in /public and /src/assets

Copy src/layouts/Layout.astro from astro-wpress and tweak

Copy src/components/Footer.astro, Header.astro, Menu.astro from astro-wpress and tweak

Copy src/styles/astro-wpress.css and rename astro-local.css

Copy src/data/menu_definition.js from astro-wpress

Copy src/pages/index.astro from astro-wpress and tweak. At this point Home page burst into life.

Copy src/utils from astro-wpress

Top

Search

I thought initially that this would not be possible with a static site, but Astro has an ingenious solution.

At build time it generates a compact index which the client only downloads if the search box is clicked.

% npm install fuse.js

Top

RSS

astro-wpress gets feed from ncvp.me/wp. This is not possible for locally sourced blog.

How can we get it from the cloud astro site? This would be better for astro-wpress as well.

astro-blog

Works as supplied in blog template.

Useful reference.

astro-wpress

Some subtleties, particularly in /src/pages/rss.xml.js due to the fact that this is a front end to a headless WP site.

% npm install @astrojs/rss

Configure site url in /astro.config.mjs

export default defineConfig({

...

site: 'https://astro-wpress.ncvp.me',

...

});

Create /src/pages/rss.xml.js

Add to <head> in Layout.astro:

<link rel="alternate" type="application/rss+xml" title="astro-wpress.ncvp.me" href={`${Astro.site}rss.xml`} />

Top

Menu

/scripts/get-menu.mjs gets the menu via the WP REST API and builds menu_definition_auto.js in /src/data

Check carefully against menu_definition.js and replace when OK

Add to package.json manually

...

"scripts": {

"get-menu": "node scripts/get-menu.mjs",

...

Run with

% cd ~/winxp/projects/astrojs/astro-local

% npm run get-menu

Top

Gemini comments

Other editorial possibilities

1. Decoupled CMS (Headless)

If you like the "dashboard" feel but want something more modern or specialized than WordPress, look at:

Payload CMS: This is currently the "darling" of the Astro community. It’s a Node.js-based headless CMS that is incredibly flexible. You can run it locally (just like WP) or host it. It uses TypeScript, so it integrates perfectly with your Astro constants and types.

Sanity.io: A cloud-based CMS where you define your "schema" (fields) in code. It has a great real-time editor and an Astro integration that makes fetching data very simple.

2. Git-Based CMS (The "MD" Evolution)

Since you’ve already worked with Markdown files, these tools provide a visual UI on top of your .md or .mdx files. They don't need a database; they just commit changes to your Git repo.

Decap CMS (formerly Netlify CMS): An open-source classic. It adds an admin dashboard to your site that lets you write posts, and when you hit "Save," it commits a Markdown file to your repo.

TinaCMS: This is the most impressive "modern" choice. It allows for Visual Editing, where you click on a heading directly on your Astro site and type to change it. It saves the changes back to your Markdown files.

3. Keystatic (The "Local-First" Winner)

Since you are currently enjoying a local-first workflow with Xubuntu and symlinks, you should definitely check out Keystatic.

It was built specifically for the "Astro/Next.js" era.

It has no database. It’s a beautiful UI that runs in your browser but saves everything as local files in your project.

It handles image uploads brilliantly—it will save them directly into your public/ folder without needing symlinks or rsync.

Comparison for a WP User:

Feature WordPress Keystatic TinaCMS
Data Source MySQL Database Local Markdown/JSON Git-based Markdown
Interface Familiar / Heavy Minimal / Clean Visual / Live
Images Media Library Local Folder Local Folder/Cloud
Astro Setup REST API Fetch Local File Import GraphQL/Git

My Recommendation: If you want to stick with a "Local Build" workflow but want to get away from the overhead of a full PHP/MySQL WordPress install, try Keystatic. It gives you a clean editorial UI while keeping everything as simple files on your hard drive.

Top

Rendered by src/pages/[slug].astro