decaporg / decap-cms

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

Adding a widget that will automatically generate URL when new post is created #7185

Closed mohammedasker closed 2 weeks ago

mohammedasker commented 2 months ago

Hello. I have a job board website that is built with Eleventy (11ty) and Decap CMS. I want to add a widget that will automatically generate the URL of posts I created from Decap CMS. The reason why I want it is so that every time I create new job posts, it will automatically add a URL in the markdown front matter. I need these URLs so that they will show up in Google Rich Results and improve the SEO of my website.


collections:
  - name: "blog"
    label: "Blog"
    folder: "src/blogs"
    create: true
    slug: "{{year}}-{{month}}-{{day}}-{{slug}}"
    fields:
    - { label: "Title", name: "title", widget: "string" }
    - { label: "Post URL", name: "posturl", widget: "slug" } <--- something like that

---
title: Sample post
posturl: https://www.example.com/blogs/2024-04-16-sample-post/ <--- creates url in markdown frontmatter
---

I don't see any examples in the documentation, so I was wondering if it is possible to do it.

martinjagodic commented 2 weeks ago

@mohammedasker please refer to Custom Widgets to do this.

Closing the issue as it's more of a discussion/help topic.