What type do custom layout pages belong to?


This is possibly a super basic question, but sadly, I just stumbled upon it. I just wanted to know what ‘kind’ of a page is one with custom layout.

Basically, I have a contact page set-up like this: contact.md in my content folder with the frontmatter consisting of layout: contact. Then, I created a contact.html inside layouts/page/.

I have a breadcrumb navigation on all my pages which is rendered conditionally. I have it set-up for {{- if .IsSection -}}, {{- else if eq .Kind "term" -}} and {{- else if .IsPage -}}. The contact page seems to use the final condition, but that adds an empty <li> to my breadcrumb because that condition is supposed to render the section of the page which is none for the contact page.

This is my final condition:

{{- else if .IsPage -}}
			<a href = "/{{- .Section -}}/">
				{{- humanize .Section -}}
			<span uk-tooltip = "You're here">
				{{- .Title -}}
	{{- end -}}

So, for the contact page, I want to directly skip to the {{- .Title -}}. How can I distinguish pages from my regular markdown content pages?

There is no special Kind for pages with custom layout as far as I know.

In your condition above you can try wrapping the first li in a condition to render it only if the present page is the child of Section.

Something like:

{{- with .Section -}}
			<a href = "/{{- . -}}/">
				{{- humanize . -}}
{{- end -}}

If the above does not work, also check out the other Section Page Variables & Methods that may be of use.

That does work perfectly. Thanks!

One more thing, that I forgot to post above.

Instead of using hardcoded constructs like this one: /{{- . -}}/
It’s better and more portable to use {{- . | relURL -}}

Also if the project is multilingual instead of relURL one can use relLangURL

1 Like

I didn’t know that. Thanks!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.