Is there a way to include a .Page within a .Page?

Not sure if this can be done, but it is possible to include a page within a page from two different sections?

I have:


And I want to include at the end:


So when I visit /section-a/this-post/ I see both posts.

I tried with shortcodes, but no dice!

This can be done with shortcodes. What have you tried so far?

I am doing this without shortcode. In the template I add the following:

<footer id="authorinfo">
  <div class="container">
    <div class="row">
      <div class="col-12">
        {{ with .Site.GetPage "page" "sitewide/" }}
          <div id="authorfooter">
            <h3>{{ .Title }}</h3>
            {{ .Content }}
        {{ end }}       

This would probably go well in a shortcode if you need to print it inside of a page content instead of the footer.

The files header looks like the following:

title: "Title"
headless: true

This should result in no extra page created for this.

This is a Hugo 0.35+ feature.

1 Like

I tried a shortcode:

   {{ range .Site.Pages "Jobs" }}
        {{ . }}
    {{ end }}

And it gives the following error:

executing "partials/disqus.html" at <where .Site.Pages .P...>: error calling where: regular-full isn't a field of struct type *hugolib.Page

The thing is that I want to access not just the content, but the styles and everything in that page. Not sure how to do it without going the jQuery way of reading the file itself.

My structure is:


I want to have some-page.html show, styles and all, inside subscribe.html


Solved it!

{{ range .Site.Pages }}
  {{ if eq "Jobs" }}
    {{ partial "article_templates.html" . }}
  {{ end }}
{{ end }}

That can go in a shortcode and works!

Thanks Hugo!