Here are my answers to the 5 most common questions I hear content authors ask:
1. Is there a way to add default values for fields?
Having default fields in Contentful is a helpful way to speed up a content author's workflow, ensure certain fields aren't left empty and provide a starting place for them to build their content off of.
Adding a default value for a Contentful field is now possible from your content model settings:
Go to the Contentful dashboard.
Click Content Model.
Click the content type that has the field you would like to add a default for.
Within that field, click "settings."
Click the "Default Value" tab.
Enter the desired default value.
Now, when your content authors edit this field, it will be pre-filled with the content you specify.
2. How can I embed videos from YouTube or Vimeo in a Contentful component?
Embedding videos hosted on YouTube or Vimeo in Contentful isn't as obvious as doing something like adding an image or basic text field to a page. But the method for achieving this isn't as difficult as it may seem.
The best way to add videos hosted on YouTube or Vimeo is by creating a content item to hold the hosted video's ID. The video ID is provided when you click the Share button on a YouTube or Vimeo video; it's the characters after the slash:
https://youtu.be/_4kHxtiuML0 < this is the id https://vimeo.com/606811537
Your content model can be designed to have a few fields, namely:
YouTubeID: Short Text VimeoID: Short Text
You can then build upon this model to allow content authors to adjust the video's thumbnail or start time.
Then, you can have your front end set up to render a video from the ID provided.
3. "Contentful updates the URL for the asset every time you update the asset itself. So what should I do for PDFs that change over time?"
Linking directly to a PDF in the Contentful Media Library is easy if the PDF won't change:
Add a PDF to the Contentful media library.
Once the PDF is uploaded to Contentful, publish the entry.
Click the ⬇️ download icon, which will open the PDF in a new tab.
Copy the URL in the address bar.
If your PDF changes over time, however, this URL will not automatically update to show the new PDF. So, if you sent that PDF link out and later find a typo, you'd have to send a completely new link to the updated PDF.
You can get around this issue with some content modeling:
Create a content type.
Title it 📄 PDF Component.
Add one Media field with the title "PDF File."
Add one short text field with the title "Slug."
What we're doing is creating a page to host your PDF on, and specifying the URL the PDF should live at with the slug field. This way, the PDF will update whenever you change the file in the PDF File field, but the URL will stay the same.
Developer note: you can find code snippets to help implement this solution on the front end here.
4. How can I break text into two lines in non-rich text fields?
Having the right amount of characters on each line of text is key to optimizing readability, so it makes sense why authors would want to customize text fields in this way.
To add line breaks to text fields, you can have your front end set up to add line breaks whenever an author adds a <br> element to a text field.
For content authors, the experience would look something like this:
That text would render as:
This is what it will look like
at this point
Developer note: To learn more about how to implement this from a technical perspective, take a look at our guide here.
5. "I can’t seem to figure out how to add a jump link. I want to be able to specify different points throughout my site pages to link to specifically."
Jump links are used when you want to send someone to a specific position on a page.
To create a system to specify jump link positions on your site, you can follow these steps:
Create a content type and title it 🦘 Jump Link Component.
Add a short text field titled Component Name.
Add a short text field titled Identifier.
Click on the Identifier field settings and then the validation tab.
Select Prohibit a specific pattern and add /^\S+$/ to the regex input field. This will prevent users from being able to type spaces into this field (if spaces are added here, you cannot generate the proper jump link)
Now, as an example, let's say you wanted to link to the About Us section of your homepage:
You would navigate to the page component for your homepage (not sure how to model a basic page component? More on that here).
Then, find your About Us section on that page.
Create a new 🦘 Jump Link Component and reference it above the About Us section.
Create links to this section combining the page link with the identifier set in the 🦘 Jump Link Component. In the example of the About Us section, the link would look something like www.yoursite.com/#about-us-section
Developer note: you will need to configure your front end to add a <div> with an id that matches the identifier wherever a 🦘 Jump Link Component is added.
Content authors have been through a lot
Working with a traditional CMS is tough, and using a headless CMS promises a better way. Making the switch to a headless CMS is an opportunity to make a CMS work for you specifically.
There's a process you can follow to make Contentful work for your team specifically
It's called the Waterfall method.
Teams I've worked with that follow this process were far more likely to set up a successful Contentful project than those who didn't.
Why? Because the process uses your current challenges to inform a vision their entire team can work towards, and make Contentful the tool to pull it all together.