decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.7k stars 3.03k forks source link

How to add date prefix (2023-01-12-my-post) in slug? #6652

Closed snowmanstudio closed 1 year ago

snowmanstudio commented 1 year ago

my project structure like this-

-blog
--2023-01-12-hello-world.md
--2023-01-11-second-post.md
-src
--admin
---index.html
---index.js
---config.yml
-static

When I post in NetlifyCMS post published in my blog folder. In my site this post is published with subfolder like this example.com/blog/my-netlify-post I don't want to include /blog/ in my url It should be like this example.com/my-netlify-post

-blog
--my-netlify-post.md
--2023-01-12-hello-world.md
--2023-01-11-second-post.md

my config.yml code:

backend:
  name: git-gateway
  branch: main # Branch to update (optional; defaults to master)

media_folder: "static/uploads"
public_folder: "/uploads"

collections:
  - name: "post"
    label: "Post"
    folder: "blog"
    create: true
    slug: "{{slug}}"
    fields:
      - {label: "Title", name: "title", widget: "string"}
      - {label: "Excerpt", name: "excerpt", widget: "string"}
      - {label: "Category", name: "category", widget: "string"}
      - {label: "Tag", name: "tag", widget: "string"}
      - {label: "Publish Date", name: "date", widget: "datetime"}
      - {label: "Body", name: "body", widget: "markdown"}
martinjagodic commented 1 year ago

Hi @snowmanstudio, you should probably solve that with your static site generator. Decap CMS enabled editing files, but rendering them on a site is a task for a different tool.