I want to create a JSON and an index page that excludes posts from one subsection. I have the subsections inside the posts folder in content. I have tried different examples in this forum including this one and this one but none works.
Edit: I am using front matter variables for now as a workaround. But I would prefer if I could do this at the subsection level without relying on front matter.
I think what you need is .CurrentSection. From the docs:
.CurrentSection
The page’s current section. The value can be the page itself if it is a section or the homepage.
compared to:
.Section
The section this content belongs to. Note: For nested sections, this is the first path element in the directory, for example, /blog/funny/mypost/ => blog .
EDIT: But I don’t used nested sections, so I make no promises…
You also need to include it in the relevant template for the JSON output format.
In any case as @cshoredaniel mentioned above you may need to share a sample of the project that reproduces the setup, so that we can see where the problem lies.