Giter VIP home page Giter VIP logo

hubspot-to-contentful's Introduction

WordPress to Contentful

Migrate WordPress posts to Contentful using the WP REST API and the Contentful JS SDK.

  • Markdown: Post bodies are converted to Markdown to strip out inline styles and image dimensions.
  • Assets: Featured and inline images will be transferred and their references in content replaced.
  • Authors: Script looks for CF Person names that match WP User and reassign author attribution.
  • Date Published: Preserved

๐Ÿš€ Usage

  1. Prerequisites
  2. yarn install
  3. yarn start

โš ๏ธ Prerequisites

Webhooks

Make sure to temporarily disable any publish webhooks (e.g. Netlify) because this is gonna do a lot of publishing.

Globally installed

Contentful Content Types

Assumes the following content types are already created in Contentful:

Person: person

For best results, create Persons with matching names so posts authors in the two systems can be matched up and attributions preserved. Otherwise, the fallback Person ID will be used.

Blog Post: blogPost

See fields in source

Contentful Content Management API

Contentful CMA tokens have access to all environments for migration purposes so make sure to double-check the relevant config var to see which is being targeted.

WP Users API route

The /wp-json/wp/v2/users should return a paginated list of users, if it does not and returns an error like the one below (via Wordfence) it will need to be enabled before the author tasks can run effectively:

{
  "code": "rest_user_cannot_view",
  "message": "Sorry, you are not allowed to list users.",
  "data": {
    "status": 401
  }
}

โš™๏ธ Config

Values required for all of the variables below, or the test config (first) task will throw.

# Base URL for API requests
WP_API_URL="https://website.com/wp-json/wp/v2"

# WP returns absolute URLS, we use relative
REDIRECT_BASE_URL="https://website.com"

# Generated in web app interface
CONTENTFUL_CMA_TOKEN="[token]"

# Go to Project's Settings > General Settings
CONTENTFUL_SPACE_ID="[space-id]"

# Sandbox environment name, or master
CONTENTFUL_ENV_NAME="[staging]"

# Default locale (in my case "en-US")
CONTENTFUL_LOCALE="[locale]"

# "Person" ID used when a match cant be found
# comparing WP User to CF Person names (post
# author attribution)
CONTENTFUL_FALLBACK_USER_ID="[id]"

๐Ÿ™ Cite

Lots of inspiration from this article and linked gists, it inspired the general approach and some of the of code is used directly.


โ˜‘๏ธ Goals

  • Replace Listr with Ink static & dynamic logging
  • Optional, incremental steps
  • Multi-phase approach
    1. Migrate content to sandbox env
    2. Export structure/content using CF Migration CLI
    3. Use CF tooling to migrate content into master

hubspot-to-contentful's People

Contributors

chrisski avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.