DEV Community

David Boland
David Boland

Posted on • Originally published at davidboland.site on

Contentful Most Frequently Asked Questions

Working with Contentful as much as I do, I am pretty active within the community. Whether it's the Contentful's forums, their Slack community, or DMs, I come across a lot of questions.

Most are specific to a given implementation. However, there are many general questions that get asked over and over. Since they keep getting asked, I figure the answers aren't the easiest to find online. This post is an effort to get those answers out there.

As I come across more questions, I will continue to add to this page.

Setting Alt Tags For Images in Contentful

To implement alt tags with Contentful images, you have two options. You can either use the existing description field, or you can create a custom model for your images.

For basic implementations, using the existing description field works fine for alt text. However, if you have a more complex implementation, you may want to create a custom model. This is especially true if you need to have additional data associated with your image. There is some Contentful documentation describing adding additional metadata to an asset.

Maximum Image Size in Contentful

According to their technical specifications, the max size of an image uploaded into Contentful cannot exceed 20MB. Anything beyond 20MB will be treated as an asset.

This can throw some people off, because uploading a larger image will not throw any errors. However, you will not be able to leverage any of the image manipulation tools offered by their API. So make sure you compress any images that exceed 20MB before uploading.

Copying Models Between Spaces in Contentful

To move content models between spaces or environments, Contentful provides import/export functionality via their CLI.

Contentful's CLI (Command Line Interface) can also migrate entire spaces and environments. This includes content models, roles, assets, content, and webhooks. You can find documentation and examples on Contentful's site.

Restrict Editors to Specific Content Types or Fields in Contentful

Contentful allows for restricting editors to specific entries, content types, and fields. This can be configured in Contentful settings by navigating to Settings > Roles & Permissions > Edit a Role.

Contentful Roles and Permissions

Using Contentful Tokens in the Client (Front End)

Because Contentful's Content Delivery and Content Preview APIs are read only, you can use the tokens in the client without issue.

You will need to use caution when using the Content Preview API token. If you have any unpublished content then it would be accessible through with this token.

Preview Contentful Changes with a Static Website

Static websites require a new build after any content changes. Because of this, you cannot immediately preview changes made in Contentful.

If using a site generator such as Gatsby, you can leverage tools like incremental builds to decrease the build time. For this, you can setup a separate site that leverages the Content Preview API, as well as incremental changes.

Error When Creating New Contentful Environment

When creating a new environment, in order to avoid errors in your implementation, you must add your environment to any existing API keys.

This can be done via Settings > API keys > then selecting your desired key. At the bottom you will see an option for Environments. Select your newly created environment to ensure it is accessible via your the API.

I hope this helps! If you do have questions about an implementation, feel free to reach out to me.

Latest comments (0)