I must be missing something simple but I didn’t see it looking through docs and here.
I creating schema.org json+ld for my site and want to use different microdata depending on the page location in a nested section, but I can’t figure out how to elegantly test this.
GIven a simple example:
content/
├── about/
├── _index.md
├── employment/
├── _index.md
├── job.md
How can I test when job.md is in the section employment?
If it were a top level section check a simple {{ if eq .Section "about" }} would work for instance. Is there a similar approach for checking if the page is under the employment nested section?
From job.md, the .CurrentSection method gives you a page reference to content/about/employment/_index.md.
So you can do:
.CurrentSection.Title
.CurrentSection.RelPermalink
etc.
That makes sense. I guess I was thinking there might be something similar to .Section to avoid any fragility in the title change of the employment list page. 
Once you have the page reference you can get to .File, so…
{{ .CurrentSection.File.ContentBaseName }}
Aha! Now it’s something new and shiny to play with. Thank you!
If you go this route, you’ll need to code defensively for section pages that aren’t backed by a file.
{{ $foo := "" }}
{{ with .CurrentSection }}
{{ with .File }}
{{ $foo = .ContentBaseName }}
{{ end }}
{{ end }}
{{ $foo }}