You can clone/copy and modify this repo to your liking.
Your markdown-exported Wordpress blog posts should be placed in: pages/posts/
Please see this blog for details:
👉 How to Convert a Wordpress blog to Astro Static Site Generator
- Follow the instructions in the companion blog post to export your Wordpress posts and content.
- Clone or copy this project.
- Place your markdown-ified Wordpress posts in
src/posts
. - Place your mirrored
wp-content
folder inpublic/
. The most important subfolder of this iswp-content/uploads
, which contains your pictures. You might or might not need the rest. - Install project dependencies by running
npm install
(assuming you have Node.js installed) - Disable Astro telemetry:
./node_modules/.bin/astro telemetry disable
(this only needs to be done once) - Run
npm run build
to generate site indist/
and check for errors - Run
npm run dev
to serve the site locally and monitor files for changes. You can make any modifications as needed to the files undersrc/
so that your blog looks and behaves the way you'd like it - Don't forget to update files
astro.config.mjs
andconfig.ts
with values that are relevant to your website!
When you run npm run build
, your website will be saved to the dist/
folder. How you'd like to deploy it then is up to you. There are many options.
Finally, there are some things to keep in mind:
- The following frontmatter is required:
title
,date
,author
,layout
,permalink
,categories
,tags
- The following frontmatter is optional:
draft
,id
- You can set
draft: true
to prevent a post from appearing on the generated website - Make sure that the URL in
permalink
begins and ends with a/
- You should generate the
date
value indate
like so:node -e "console.log(new Date().toISOString())"
- Many of the newly added files do not fit in with the markup and styling of the original template, and probably won't fit in with the styling and markup of your Wordpress site either. You will need to modify them to look good.
- When making changes to the template, if things suddenly don't work, try running
npm run build
instead ofnpm run dev
, as that seems more likely to identify and catch bugs.
This project is fork of version 1.1.0
of the create-astro
project.
The following differences exist:
- Wordpress-specific modifications:
- URL preservation:
pages/[...wp].astro
: preserves original wordpress permalinks for posts, as defined by the frontmatterpermalink
pages/author/[slug].astro
: wordpress-URL for listing posts for specific authorpages/category/[slug].astro
: wordpress-URL for listing posts for specific categorypages/tag/[slug].astro
: wordpress-URL for listing posts for specific tagpages/page/[page].astro
: wordpress-URL pagination support for listing all of your posts on the homepage- The orignal template's
src/pages/blog/
folder has been removed. Posts now go insrc/posts/
- Components:
src/components/WPArticleSummary.astro
: two ways of showing post summaries on main page (with or without<!--more-->
comment)src/components/PostFooter.astro
: optional footer under posts to link to related categories, tags, etc.src/components/Sidebar.astro
: sidebar widgets to list categories and recent postssrc/components/Search.astro
: non-functioning search widget. Feel free to implement it and send a PR!
- URL preservation:
- Added the following dependencies:
remark-breaks
: better newline handling in markdown filesremark-gfm
: support for rendering tables in markdown files@remark-embedder/core
&@remark-embedder/transformer-oembed
: support for rendering Twitter and YouTube links as embeds
src/pages/rss.xml.js
: superior RSS generation- Added support for
@
in imports to make it easy to import files without using../../../
etc. - Added
PAGE_SIZE
config variable tosrc/config.ts
.npmrc
now usessave-exact = true
(What follows is the original unmodified README from the official Astro blog template.)
# okTurtles Note: DO NOT DO THIS!
# Clone this repo, or download a zipped version of it instead.
# Running the command below will install the unmodified version
# of the Astro blog template, which doesn't have Wordpress support.
npm create astro@latest -- --template blog
🧑🚀 Seasoned astronaut? Delete this file. Have fun!
Features:
- ✅ Minimal styling (make it your own!)
- ✅ 100/100 Lighthouse performance
- ✅ SEO-friendly with canonical URLs and OpenGraph data
- ✅ Sitemap support
- ✅ RSS Feed support
- ✅ Markdown & MDX support
Inside of your Astro project, you'll see the following folders and files:
├── public/
├── src/
│ ├── components/
│ ├── layouts/
│ └── pages/
├── astro.config.mjs
├── README.md
├── package.json
└── tsconfig.json
Astro looks for .astro
or .md
files in the src/pages/
directory. Each page is exposed as a route based on its file name.
There's nothing special about src/components/
, but that's where we like to put any Astro/React/Vue/Svelte/Preact components.
Any static assets, like images, can be placed in the public/
directory.
All commands are run from the root of the project, from a terminal:
Command | Action |
---|---|
npm install |
Installs dependencies |
npm run dev |
Starts local dev server at localhost:3000 |
npm run build |
Build your production site to ./dist/ |
npm run preview |
Preview your build locally, before deploying |
npm run astro ... |
Run CLI commands like astro add , astro check |
npm run astro --help |
Get help using the Astro CLI |
Check out our documentation or jump into our Discord server.
This theme is based off of the lovely Bear Blog.