Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

📝Docs - Guide to migrate from WordPress #2411

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
5 changes: 5 additions & 0 deletions content/docs-toc/docs-toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@
"slug": "content/docs/guides/internationalization.mdx",
"_template": "item"
},
{
"title": "Migrating From WordPress",
"slug": "content/docs/guides/converting-wordpress-to-tina.mdx",
"_template": "item"
},
{
"title": "Migrating From Forestry",
"items": [
Expand Down
129 changes: 129 additions & 0 deletions content/docs/guides/converting-wordpress-to-tina.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
---
title: Migrating WordPress Content
last_edited: '2024-11-04T04:31:04.917Z'
next: ''
previous: ''
---

## Introduction

This guide is a walkthrough using a **WordPress to Markdown converter**, which is recommended for most use cases where you want to migrate your content from WordPress to Tina.

Other conversion options that are not covered in this guide include:

- Using the WordPress Rest API - best for extracting the pure html for page or post content in JSON format
isaaclombardssw marked this conversation as resolved.
Show resolved Hide resolved
- Using the WPGraphQL plugin - best for cases where you want to query and extract specific data and content

## Prerequisites

- [Node.js](https://nodejs.org/) is installed
- You have set up a [Tina starter](https://tina.io/docs/introduction/using-starter)
Comment on lines +19 to +20
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a warning callout that says the scope of this guide. Or specifically why we're using the Tina starter (creating a new site, whereas someone might expect we can somehow copy the old one's html/css implementation).

i.e. this is largely a data transfer guide.


## Getting Started

### Converting WordPress to Markdown

1\. Export your Wordpress content by going to [https://wordpress.com/export/](https://wordpress.com/export/) and select **Export All**

> 💡 **Note:** Name it **export.xml** to make it easier for you in the next step

Use [wordpress-export-to-markdown](https://github.com/lonekorean/wordpress-export-to-markdown) to convert your WordPress content into Markdown.

2\. In the folder where you've saved your exported file **export.xml**, run:

```powershell
npx wordpress-export-to-markdown --post-folders=false --include-other-types=true
```

3\. When prompted, make sure the filename is correct, and use the default values for the other prompts.

This creates an `output` folder that groups your posts and pages into separate folders.

### Import data to TinaCMS

#### Migrating images to TinaCloud
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TinaCloud isn't involved here. Also capitalisation.

Suggested change
#### Migrating images to TinaCloud
#### Migrating Images


1\. In the output folder, drag the image folders `output/post/images` and `output/page/images` to your Tina app's `public/uploads` folder.

> 💡 **Note 1:** You can rename the folder before dragging to prevent duplicate image names being replaced

> 💡 **Note 2:** You can also set up alternative hosting with your preferred media manager.
Comment on lines +48 to +50
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we trying to make "Note" happen on the Tina docs? We could, but there's no precedent anywhere else – needs some discussion on what tone we want and how we want to enforce it.

Currently
I've been auditing every docs change and trying to keep the same style – not really sustainable.


#### Migrating Posts

1\. Navigate to your output's posts folder `output/post`, and run:

```powershell
ren * *.mdx
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a MacOS command as well?

```

Which will convert your files from Markdown to MDX.

2\. Drag all the MDX files in `output/post` to your Tina app's `content/posts` folder, now your posts have been migrated to Tina!
Comment on lines +52 to +62
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention it's a happy accident that the WP post format happens to match the one in the starter? It's not usually this easy


#### Migrating Pages

<WarningCallout body="If you are having trouble with this step, feel free to contact a developer for assistance in the chat, or through one of our community channels." />
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't believe they can talk to a real person via the chat – should link to our discord maybe


1\. Create a new folder in your Tina app's `content` folder named `wp-pages`.

2\. Create a new file in your Tina app's `tina/collection` folder named `wp-page.ts` and use the template below, you can change this later to fit your page's schemas better.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a big reduction – what kind of data do we get in these WP markdown files specifically? Should they set up block based editing? How can we look at the converted data and turn it into a schema?

Do we want a seperate guide that goes over general migration tips (ex. this is the markdown we have, how can we create a schema that fits it) – then we could just link that and use the wordpress markdown as the example

Counterargument
This guide looks really straightforward as is – which is great.


```javascript
import type { Collection } from 'tinacms';

const WpPage: Collection = {
label: 'Migrated WordPress Pages',
name: 'wppage',
path: 'content/wp-pages',
format: 'md',
fields: [
{
type: 'string',
label: 'Title',
name: 'title',
isTitle: true,
required: true,
},
{
type: 'rich-text',
label: 'Body',
name: '_body',
isBody: true,
},
],
};

export default WpPage;
```

3\. Import your created collection to the [schema](https://tina.io/docs/reference/schema) in `tina/config.tsx`.

```javascript

import WpPage from "./collection/wp-page";
...

schema: {
collections: [Page, Post, ..., WpPage],
},
```

### View and Edit your migrated content

1\. At the root of your Tina app, run:

```powershell
npm run dev
```

2\. Go to `localhost:3000/admin`

3\. Go to the Migrated WordPress Pages and Blog Posts collections, then to the Media Manager. You can now view and edit your migrated posts, pages and images!

## Next Steps

- Adding a coverImage field to your post schema to read the image
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be included in the guide

- Update the image links in the Markdown and MDX files to match how Tina uses them, uploads/image.png
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably be included in the guide

- Making changes to the themes and any missing features from the exporter
- Take advantage of [npm packages](https://www.npmjs.com/) to replace WordPress plugins functionalities