I would like to bring to your attention a (to me) inconsistent behaviour:
fileExists will be true whether or not index.md is given but .SiteGetPage only works if index.md is added. This really threw me as I first tested whether the file existed - it did - but then it did not print the title.
Not necessarily. .Site.GetPage also works for Section and Nested Section lists with an _index.md.
Not sure why you’re performing the following check in your templates:
<h2>Without index.md</h2>
{{- $url := "/states/rajasthan/cities/jaipur/excursions/amber-fort-sightseeing/" }}
fileExists: {{- fileExists $url }}<br>
Title using GetPage: {{ with .Site.GetPage $url }}{{ .Title }}{{ end }}<br>
{{- $urlmd := printf "%s%s" $url "index.md" }}
<h2>with index.md</h2>
fileExists: {{- fileExists $urlmd }}<br>
Title using GetPage: {{ with .Site.GetPage $urlmd }}{{ .Title }}{{ end }}<br>
{{ end }}
In the first instance you are simply checking for the PATH without index.md /states/rajasthan/cities/jaipur/excursions/amber-fort-sightseeing/
And yes the file exists, as in the rendered Page exists.
I was merely trying to point out the imho inconsistencies between the two commands i.e. GetPage and fileExists.
I now understand that my problem was that I did not trim the trailing / in the .GetPage command. This is not clear in the docs. At least I had read it several times and it did not occur to me to verify this.