String fields have newlines added to Markdown metadata (front matter) which breaks Pelican

I am using Netlify CMS to manage content in a Pelican site. Pelican uses metadata at the top of markdown files for fields. When I allow users to add more than approx. 80 chars to a String field, Netlify CMS is adding a newline character to the content of the String field at about 80 chars in.

Pelican does not expect newlines in the metadata so it breaks and doesn’t generate the content.

I’ve added a character count limit using regexp pattern, but 80 chars is a lot fewer chars than I’d like for some fields. Can anyone help?

  - name: "news-articles" # Used in routes, ie.: /admin/collections/:slug/edit
label: "News & Articles" # Used in the UI, ie.: "New Post"
folder: "content/news-articles" # The path to the folder where the documents are stored
sort: "date:desc" # Default is title:asc
create: true # Allow users to create new documents in this collection
fields: # The fields each document in this collection have
  - {label: "Title", name: "title", widget: "string", tagname: "h1", class: "entry-title"}
  - {label: "Image", name: "img_src", widget: "image"}
  - {label: "Image Alt Text", name: "img_alt", widget: string, hint: "Text shown to visually impaired users instead of image. 80 chars or less, no newlines", pattern: ["^[^\n\r].{3,80}$", "80 characters or less. No newlines."]}
  - {label: "Image Title", name: "img_title", widget: string, required: false, hint: "Title shows when mouse hovers on image", pattern: ["^[^\n\r].{3,80}$", "80 characters or less. No newlines."]}
  - {label: "Keywords", name: "keywords", widget: string, required: false, hint: "Separate keywords with commas, 80 chars or less, no newlines", pattern: ["^[^\n\r].{3,80}$", "80 characters or less. No newlines."]}
  - {label: "Summary", name: "summary", widget: string, required: true, hint: "Keep it short, 80 characters or less, no newlines", pattern: ["^[^\n\r].{3,80}$", "80 characters or less. No newlines."]}
  - {label: "Body", name: "body", widget: "markdown", class: "article-body"}
  - {label: "Publish Date", name: "date", widget: "datetime"}

Hi @Marcus_Clements and welcome to the community :slight_smile:

I’ve tried using the following config:

collections:
  - name: 'news-articles' # Used in routes, ie.: /admin/collections/:slug/edit
    label: 'News & Articles' # Used in the UI, ie.: "New Post"
    folder: 'content/news-articles' # The path to the folder where the documents are stored
    create: true # Allow users to create new documents in this collection
    fields: # The fields each document in this collection have
      - { label: 'Title', name: 'title', widget: 'string', class: 'entry-title' }

And was able to generate a file with a title of more than 80 chars with no line breaks.
This is the content of the file generated by the CMS:

---
title: testtesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttesttest
---

Can you make sure you’re using the latest version of the CMS?

If that doesn’t work can you please open an issue with a reproduction here: