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

Define path for collection fields, to organize subpages/subpage urls #5769

Closed
curtiswallen opened this issue Aug 30, 2021 · 1 comment
Closed
Labels
area: nested-collections duplicate type: feature code contributing to the implementation of a feature and/or user facing functionality

Comments

@curtiswallen
Copy link

curtiswallen commented Aug 30, 2021

Is your feature request related to a problem? Please describe.

I am using Netlify CMS and Hugo to create a website for a gallery and want to have a main landing page for each artist, e.g.:
/artists/andy-warhol

But then have links on that page that go to subpages for the artist's biography, exhibition history, etc., e.g.:
/artists/andy-warhol/bio

Unless I am missing something, this is not currently possible with Netlify CMS, because I cannot structure the content files as needed, e.g.,

content/artists/andy-warhol

  • index.md
  • bio.md
  • exhibitions.md

Describe the solution you'd like

I'd like to be able to define paths within individual fields, which would then output that specific front matter content to its own markdown file. That way I could create the markdown file structure outlined above, so that Hugo will generate the proper url paths.

Something like the below (feature request bolded):

 - name: "artists"  
    label: "Artists"  
    identifier_field: "name.last"  
    slug: "{{name.first}}-{{name.last}}"  
    summary: "{{name.first}} {{name.last}}"  
    folder: "/content/artists"   
    path: "{{slug}}/index"  
    create: true   
    fields:   
      - label: "Artist name"   
        name: "name"  
        widget: "object"  
        summary: '{{fields.first}} {{fields.last}}'  
        fields:   
          - {label: "First Name", name: "first", widget: "string"}  
          - {label: "Last Name", name: "last", widget: "string"}  
      - label: "Main Image"  
        name: "main_image"  
        widget: "image"  
      - label: "Image Gallery"  
        name: "image_gallery"  
        widget: "image"  
        media_library:  
              name: cloudinary  
              config:  
                multiple: true  
      - label: "Biography"  
        name: "bio"  
        widget: "object"  
        **path: "{{slug}}/bio"**  
        fields:  
          - {label: "DOB", name: "dob", widget: "string"}  
          - {label: "Education", name: "education", widget: "list", summary: '{{fields.degree_year}} — {{fields.degree_institution}}', fields: [
              {label: "Year", name: "degree_year", widget: "string"},  
              {label: "Degree", name: "degree_institution", widget: "string"}]}  
          - {label: "Collections", name: "collections", widget: "markdown"}  
          - {label: "Awards/Grants", name: "awards", widget: "list", summary: '{{fields.award_year}} — {{fields.award}}', fields: [
              {label: "Year", name: "award_year", widget: "string"},  
              {label: "Award/Grant", name: "award", widget: "string"}]}  
          - {label: "Selected solo exhibitions", name: "solo_exhibitions", widget: "list", summary: '{{fields.solo_exhibition_year}} — {{fields.solo_exhibition}}', fields: [  
              {label: "Year", name: "solo_exhibition_year", widget: "string"},  
              {label: "Exhibition", name: "solo_exhibition", widget: "string"}]}  
          - {label: "Selected group exhibitions", name: "group_exhibitions", widget: "list", summary: '{{fields.group_exhibition_year}} — {{fields.group_exhibition}}', fields: [  
              {label: "Year", name: "group_exhibition_year", widget: "string"},  
              {label: "Exhibition", name: "group_exhibition", widget: "string"}]}  
          - {label: "Biography PDF", name: "bio_pdf", widget: "file"}

The result of the above would be that the "name", "main_image", and "image_gallery" fields get written to:

artists/{{slug}}/index.md

And the "bio" field gets written to:

artists/{{slug}}/bio.md

With that structure I could create a template that would show the index content at the url:

/artists/andy-warhol

but then replace the image gallery with the bio info at the url:

artists/andy-warhol/bio

Describe alternatives you've considered

Maybe defining the path is the wrong approach, since the "biography" field is already a sub-field of "artists"? It could be some sort of option to give it a custom name, but always within the parent folder defined by the collection configuration?

However, there could be a case where someone wanted to write that data to a totally separate location (e.g., path: bio/{{slug}} to separate the bios into their own section, without having to input them via a separate collection?), in which case being able to define the path would be useful.

Additional context

@curtiswallen curtiswallen added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Aug 30, 2021
@erezrokah
Copy link
Contributor

Hi @curtiswallen, I believe this is partially covered using nested collections, and the rest should be covered by #4972.

If this is not covered in #4972, please comment and I'll re-open the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: nested-collections duplicate 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