Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploys fails because the Filename is too long #6987

Open
jdromero88 opened this issue Nov 21, 2023 · 3 comments
Open

Deploys fails because the Filename is too long #6987

jdromero88 opened this issue Nov 21, 2023 · 3 comments
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@jdromero88
Copy link

Currently, I'm getting the next error on Netlify when the user adds a new post 12:14:04 PM: Failed during stage "preparing repo": error: unable to create file _posts/2023-11-21-bihar-passes-the-bihar-reservation-of-vacancies-in-p-s-sc-st-obc-amendment-bill-2023-reserving-seventy-five-percent-of-positions-in-government-jobs-and-educational-institutions-for-people-from-marginalised-castes-and-economically-weaker-sections.md: File name too long

Is your feature request related to a problem? Please describe.
Yes. The team that uses the CMS is creating posts with long titles, and this is an everyday issue. I need to manually change the file name on GitHub to be able to deploy.
image

Describe the solution you'd like
Would be nice to have a way to tell the slug to use only 'x' amount of characters of the title to avoid this issue.

collections:
  - name: 'analysis'
    label: 'Analyses'
    label_singular: 'Analysis'
    folder: '_analysis/'
    create: true
    editor:
      preview: false
    slug: '{{year}}-{{month}}-{{day}}-{{slug}}'
    slug_length: 100
    sortable_fields: []
    fields:
      - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
      - { label: 'Breadcrumbs', name: 'breadcrumbs', widget: 'hidden', default: 'analysi

Describe alternatives you've considered
I know I can use pattern to limit the title field with regex, but in our use case the titles can't be shortened.

@jdromero88 jdromero88 added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Nov 21, 2023
@pkokorev
Copy link

pkokorev commented Apr 4, 2024

@jdromero88 hello ! did you find a workaround to this issue ? we ended up creating in every collection a spare- / meta- field "short title" that we don't use anywhere in the frontend code, and whose only purpose is to help decap generate shorter file names.

@jdromero88
Copy link
Author

Hi @pkokorev, no, I didn't. That's a great idea! I will try it and reach out back if I have any question. Thank you for sharing it!

@jdromero88
Copy link
Author

jdromero88 commented Jun 18, 2024

In case anyone is wondering, this is how I implemented the workaround suggested by @pkokorev. I limited the short title to 180 characters.

collections:
  - name: 'newsletter'
    label: 'Newsletters'
    label_singular: 'Newsletter'
    folder: '_newsletter/'
    create: true
    editor:
      preview: false
    indentifier_field: short_title
    slug: '{{year}}-{{month}}-{{day}}-{{short_title}}'
    sortable_fields: []
    fields:
      - { label: 'Layout', name: 'layout', widget: 'hidden', default: 'post' }
      - { label: 'Breadcrumbs', name: 'breadcrumbs', widget: 'hidden', default: 'newsletter' }
      - { label: 'Is newsletter', name: 'is_newsletter', widget: 'hidden', default: true }
      - { label: 'Content Type', name: 'content_type', widget: 'hidden', default: 'newsletter' }
      - { label: 'Title', name: 'title', widget: 'string' }
      - { label: 'Short Title', name: 'short_title', widget: 'string', pattern: ['^.{0,180}$', "Must have less than 180 characters"] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

No branches or pull requests

2 participants