Using .Site.GetPage and Pagebundles together


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

{{with .Site.GetPage "/home" }}
  {{ with .GetPage "" }}
    {{ .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 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:

└── posts
    β”œβ”€β”€ post1
    β”‚   └──
    └── post2

You can then get the home page

site.GetPage "/"
# Shortcut

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

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