Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Give this site structure:
- ```
- │ config.toml
- ├───content
- │ └───blog
- │ │ post1.md
- │ │ post2.md
- │ └───post3
- │ index.md
- │ post3a.md
- │ post3b.md
- ├───layouts
- │ │ index.html
- │ ├───shortcodes
- │ │ page-resource.html
- │ └───_default
- │ single.html
- ```
- `layouts/_default/single.html`:
- ```
- <html>
- <body>
- <h1>{{ .Title }}</h1>
- {{ .Content }}
- </body>
- </html>
- ```
- `layouts/index.html`:
- ```
- <html>
- <body>
- {{- range .Pages }}
- <a href="{{ .RelPermalink }}">{{ .Title }}</a>
- <br>
- {{- end }}
- </body>
- </html>
- ```
- From `post3/index.md`, you can then reference its page resources (`page3a.md` and `page3b.md`) with a shortcode, which lives at `layouts/shortcodes/page-resource.html`:
- ```
- {{ $page := .Page.Resources.GetMatch (.Get 0) }}
- {{ $page.Content }}
- ```
- Then in your `post3/index.md`, use the shortcode:
- ```
- ---
- title: "Post3"
- ---
- Post3 content.
- {{< page-resource "post3a.md" >}}
- {{< page-resource "post3b.md" >}}
- ```
- Which, for `/index.html`, will output:
- ```
- <html>
- <body>
- <a href="/blog/post1/">Post1</a>
- <br>
- <a href="/blog/post2/">Post2</a>
- <br>
- <a href="/blog/post3/">Post3</a>
- <br>
- </body>
- </html>
- ```
- And for `/blog/post3/index.html`, will output:
- ```
- <html>
- <body>
- <h1>Post3</h1>
- <p>Post3 content.</p>
- <p>Post3a content.</p>
- <p>Post3b content.</p>
- </body>
- </html>
- ```
Add Comment
Please, Sign In to add comment