decaporg / decaporg/decap-cms

Deploys fails because the Filename is too long

Open
#6,987 3 comments 3 reactions 0 assignees View on GitHub
area: slugs type: feature
Dominant language
JavaScript
Stars
19.4k
Forks
3.1k
Avg merge
1d 14h
Merged PRs (30d)
9

Description

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](https://github.com/decaporg/decap-cms/assets/51330062/99d00b75-c582-4e07-ac09-6a546637e6c5)

**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.
```yml
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.

Contributor guide

Open the contributing guide

Research direction

Start at the collection configuration entry point shown in the issue, focusing on how the `slug` template is interpreted when a new post is created. Trace the generated filename for a long title and add coverage for the proposed `slug_length` setting; done means configured posts produce filenames short enough for deployment without requiring title changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
content
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.