A lot of md files shown as single page

In the directory /content/handbook/ I have the following files: _index.md, manuals.md and styleguide.md
I would like all files under example.com/handbook/ to be displayed as if all the contents of the files were located in _index.md.

Does it make sense to rename the files as follows? _index.md, handbook-001.md, handbook-002.md …?

In Frontmater I made the following entry:

type: handbook

In /shortcode/handbook.html I made the following entry:
Question: Is it the right place?

{{ partial "header.html" . }}

<div class="grid">
{{ range where .Data.Pages "Type" "handbook" }}
  {{ .Content }}
{{ end }}
</div>

{{ partial "footer.html" . }}

here is a part of the _index.md

---
title: "Handbook"
date: 2018-01-03T18:48:05+01:00
type: handbook
draft: false
menu:
  main:
     name: Handbook
     url: /handbook/
     weight: 2
---

{{% section class="item-1 outline" %}} 
{{% divmd class="item-1 card-nb" %}} 
# Handbook

---
{{% /divmd %}}

{{% divmd class="item-8A card-nb" %}}

{{% handbook %}}
{{% /divmd %}}

{{% divmd class="item-4D card-toc" %}}

{{% tableofcontents %}}
{{% /divmd %}}
{{% /section %}}

Do you need to create separate pages for the sub-handbook pages too?

If no:

  • Look into Leaf Bundles in documentation. You need to rename _index.md to index.md and then access the sub-handbook pages using .Resources.

No, the names of those pages (except _index vs index) are not relevant.


Also, shortcodes cannot be defined the way you have done. I’d suggest that you directly edit the handbook layout file.

Shortcodes take the Page context in the dot… you need to use $.Page to get the page context. Also I have not used partials in shortcodes, so not sure if they even work that way… Basically the code style you have in the shortcode normally belongs to a layout file.

I renamed _index.md to index.md.
What I have to write in frontmater:
resources: handbook???

Where is the right place for this code? /_default/single.html ???

{{ partial "header.html" . }}

<div class="grid">
  {{ with .Resources.ByType "handbook" }}
  {{ range . }}
  <h3>{{ .Title }}</h3>
  {{ .Content }}
  {{ end }}
  {{ end }}
</div>

{{ partial "footer.html" . }}

Yes. Also I think it’s {{ with .Resources.ByType "page" }} and you don’t need to enter something in the front matter of your markdown resources for Hugo to find them.

Thank you for the help. It worked. My next question is, how do I change the order of the md files so that they are displayed in the correct order?

The order should be gerneral, styleguide and manuals.

Name these files in the order you need. For example 001-filename.md 002-filename.md etc

There may be a fancier way to order them but that’s what works for me.

Sorry It doesn’t work. It seems that Hugo ordered the files after the date in the frontmater date: 2018-02-10T16:24:04+01:100:

This are the manes of my files:
0001-handbook.md
0002-styleguide.md
0003-manuals.md

Ok. Hugo’s default sorting order applies in Page Bundles.

Didn’t know you had entered dates. But since you have them then {{ range . | .GroupByDate "2006-01" }} should do it.

I deleted the dates in the files but it doesn’t work. I deleted the cache from the browser. No success.

Do you have a link to a repository with your Hugo site?

Your problem is unrelated to Page Bundles.

You are using a subdomain as your baseURL in your config.toml and your site hits 404 when running hugo server.

Now I don’t recall exactly the workaround for subdomains in the baseURL -as I never needed to use one myself-. Try searching the forum.

If you uncomment your first baseURL with the top level domain and comment out the one with the subdomain you will see that your Page Bundles under /handbook/ are rendered in the correct order.

Thank you for your help. Can I order the files for the handbook by hand? When yes how?

What do you mean by hand? In the repo you linked to the md files under /handbook/ are already rendered in the order of:
Handbook
Manuals
Styleguide

and the corresponding files are:
0001-handbook.md
0002-styleguide.md
0003-manuals.md

It’s up to you what you want to do. If you feel like entering front matter parameters you can use range to render them by weight, date, or some other parameter.

If you do nothing Hugo will render them according to the default sorting order: Weight > Date > LinkTitle > FilePath

Thank you for the help. I use the weight parameter in frontmater.