Import and export content > Import space from Contentful

    Import space from Contentful

    If you want to try DatoCMS, but you created your existing project with Contentful, you can use our command-line tool to import all content from a Contentful space to a DatoCMS project.

    Setup

    First install the @datocms/cli npm package:

    npm install -g @datocms/cli

    The package exposes the datocms CLI command, that you can use to install the Contentful importer plugin:

    datocms plugins:install @datocms/cli-plugin-contentful

    What you will need

    To copy your Contentful space to DatoCMS, you will need the following information:

    Your Contentful Space ID: you can find it under Settings > General settings:

    A Contentful content management token: you can create one under Settings > API keys > Content management tokens and then clicking the Generate personal token button:

    Your DatoCMS full-access API token: create a new project, and then head to Settings > API tokens:

    Run the import

    To import all the entries and assets of your Contentful space into DatoCMS, run the following in the console, making sure to replace the placeholder values with the tokens and IDs of your project:

    datocms contentful:import --api-token=<apiToken> --contentful-token=<apiToken> --contentful-space-id=<spaceId>

    The required parameters are these:

    --api-token=<value> Your DatoCMS project read-write API token
    --contentful-space-id=<value> Your Contentful space ID
    --contentful-token=<value> Your Contentful read-write API token

    The tool also accepts some additional advanced options:

    --autoconfirm Automatically enter an affirmative response to all confirmation
    prompts, enabling the command to execute without waiting for user
    confirmation, like forcing the destroy of existing Contentful schema
    models.
    --concurrency=<value> [default: 15] Specify the maximum number of operations to be run
    concurrently
    --config-file=<value> [default: ./datocms.config.json] Specify a custom config file path
    --contentful-environment=<value> The environment you want to work with
    token
    --ignore-errors Ignore errors encountered during import
    --log-level=(NONE|BASIC|BODY|BODY_AND_HEADERS) Level of logging for performed API calls
    --only-content-type=<value> Exclusively import the specified content types. Specify the content
    types you want to import with comma separated Contentful IDs -
    Example: blogPost,landingPage,author
    --profile=<value> Use settings of profile in datocms.config.js
    --skip-content Exclusively import the schema (models) and ignore records and assets

    Known limitations

    Although highly compatible, there are some minor differences between the types of fields that Contentful offers compared to DatoCMS, so the tool will follow the following migration rules:

    • DatoCMS doesn't provide an array of strings field, so data of this kind will be converted in a single string field with comma separated values;

    • Contentful API doesn't expose presentation settings for fields, so all text fields will be set as Markdown editors (you will be able to change the presentation mode later from the DatoCMS interface);

    • DatoCMS doesn't allow a multi-paragraph text field to be the Model title, so if that's the case, no title field will be set;