Accessing "relpath" Parameter inside .Source.File

I’m looking so sort using the total relative path (including filename)

so it should be something like

{{ range sort .Data.Pages "Source.Dir" "asc"}}
{{ end }}

When I print .Source.File I get:

source.File{relpath:"sectionname/Forward.md", 
logicalName:"Forward.md", Contents:io.Reader(nil), 
section:"sectionname", dir:"sectionname/", ext:"md",
uniqueID:"475f9044fc6a44ee232717c2bdd23abe"}

So there is a parameter called relPath that I should be able to get but I can’t figure out how.

Anyone have any thoughts?

.Source.File.Path = relpath

1 Like

Perfect. Works like a charm.

For future reference, how did you know that? Where was the clue I missed?

… I went to the source:

But you can also get insights like this by looking at Godoc which only lists exported types and functions:

https://godoc.org/github.com/spf13/hugo/source

That shows that we have a documentation job to do … You should get an explanation for every exported method and type in clear text.

Perfect. Thanks.

I’m all for RTFM but first I need to know where the FM is :smile:

Now I know…