Using .Site.GetPage and Pagebundles together

Hi,

I am trying to use pagebundles inside index.html file as follows:

{{with .Site.GetPage "/home" }}
  {{ with .GetPage "index.md" }}
    {{ .Content }}
  {{ end }}
{{ end }}

where the home directory is a leaf bundle present inside the content directory. However, I am unable to display the contents of the index.md file.

Can someone please help me ? I am unable to figure out what the problem is.

Because you chose it to be.

Note that this is a little bit unortodox.

Most people keep the home page as the root, e.g:

content
β”œβ”€β”€ _index.md
└── posts
    β”œβ”€β”€ post1
    β”‚   └── index.md
    └── post2
        └── index.md

You can then get the home page

site.GetPage "/"
# Shortcut
site.Home

So the home directory is a page ? Interesting. Why is this the case ? Btw, following your suggestion, I still can’t seem to show the contents of index.md.

Edit: I believe there should be a / before home. It works now with the /.

This makes more sense to me now. Thank you :slight_smile: I’ll try adding some resources using

{{ with .Resources.GetMatch "img.png" }}
  <img src="data:{{ .MediaType }};base64,{{ .Content | base64Encode }}">
{{ end }}

for example and see how it goes.

1 Like