[Solved] Do that unless there is content in the page

Hi!

Right now, when I click the blog navbar item or the topics item, I get 5 markdown pages listed, the ones inside the blog and topics folders.

I just want a table of contents to appear if there is content inside the markdown file taken from the list file; otherwise just index the markdown files inside the content folder.

By default now there is inside the list.html file:

<main>
    <h2 class="title">{{ .Title }}</h2>
    {{.Content}} 
    {{ range (.Paginator 5).Pages }} {{ partial "list-item" . }} 
    {{ end }}

</main>

I would like to write an if statement to hide:

{{ range (.Paginator 5).Pages }} {{ partial "list-item" . }} 
{{ end }}

So that, if there is content inside the markdown file, not just the title, the {{ range (.Paginator 5).Pages }} would disappear showing the content inside the markdown file, allowing me to customize the page.

Example:

What happens right now:

content inside a markdown file is compiled, but the pages inside the content folder are listed too, I want just one of the two to be shown at a time.

I hope I have explained it well enough.

You’ll receive more help if you follow the advice at Requesting Help and share the code you have. :slight_smile:

I have solvedit, I don’t know why I didn’t think about it before :confused:

Anyway I’m gonna pay more attention next time to Requesting Help!

Would you mind sharing your solution in case someone else has the same problem?

Yes, so basically I changed the location of all the files inside topics excluding _index.md in a proper named folder and then I renamed the files inside these folders _index.md.

For example:

I had these files in the topics folder -> _index.md, ok.md

So I moved ok.md inside topics/ok/ and renamed ok.md to _index.md.

In this way I got topics/_index.md and topics/ok/_index.md.
And now I can manually customize topics/_index.md to link ok as a link without getting ok.md automatically listed.