Inconsistent rendering

I’m hoping I’ll be able to use Hugo to build a website that integrates existing markdown files, but the rendering is really inconsistent. I am hoping to drop my existing files into subdirectories and just have them rendered as-is, but Hugo seems to randomly decide one of them is a list instead of a single page.

For example, in my content directory I have:

content
├── authors
│   ├── author1.md
│   └── author2.md
└── books 
    └── book1.md
index.md

I have tried adding _index.md files to both content/authors and content/books but the problem persisted. I’ve also tried with index.md files, both in the subdirectories and as my homepage, and every possible combination thereof with no success. I once had everything render correctly, but on restarting the server, at least one of the authors was again using the list template. Sometimes both use the list template. But I can restart the server and have them change. Perhaps author1 used the list before, then author2 is, or maybe both. Then I reload and it switches again.

For testing I have very simple layout files:

layouts
├── _default
│   ├── baseof.html
│   ├── list.html
│   └── single.html
├── index.html
└── partials
    ├── head.html
    └── nav.html

My list.html

{{ define "main" }}

<div id="main-container">
<h2 class="text-center">Title</h2>
{{ range .Pages }}
<p>This is a list</p>
{{ end }}
</div>

{{ end }}

And my single.html

{{ define "main" }}

<div id="main-container">
	{{ .Content }}
</div>

{{ end }}

My test files are also very simple, with no head matter, but I’m not referencing the head matter so I assume that shouldn’t matter. author1 for example:

# Author1

# Biography
They did something.

# Bibliography
* [Book 1](/books/book1)

I’m assuming I’m just not understanding bundles, but having read the page I had assumed adding _index.md to the sub-directory would solve it, but it did not. Hence why I then tried every combination thereafter.

I realise I don’t need hugo for this small sample, but I am hoping to expand and build on it from here ,which is why I’m hoping to get this to work. Is this something that can be easily achieved?

That’s not true, there is a specification.

This will not work:

content
├── authors
│   ├── author1.md
│   └── author2.md
└── books 
    └── book1.md
index.md

This will

content
├── authors
│   ├── author1.md
│   └── author2.md
└── books 
    └── book1.md
_index.md

index.md represents a leaf bundle; it bundles everything inside it.

1 Like

That works with the simple example, but when I add real content the problem remains, although it did seem to work initially, but upon reloading the server, one of the authors again switched to the list layout. Subsequent restarts does indeed seem to randomly change which is the list page, and sometimes both are… and occasionally neither. if there’s some logic to it, I can’t deduce it.

I’ve uploaded the files to a repo to demonstrate in case anyone would like to test it.

The books entry in the navbar isn’t setup, but if you click on a link from the homepage to Book1, you can get links to Author1 and Author2, and they seem to work fine. But the authors for the other book do not, despite the fact that, as far as I can tell, there is no difference in the format of the content.

The new author files are:

# Mortimer J. Adler. 1902-2001

### Biography
American philosopher and educator, as well as founder of the Institute for Philsophical Research. Initially a high-school drop-out, he ended up taking night classes and eventually studied at Columbia university.

### Education
* Ph.D. Psychology - Columbia University, NY, NY

### Read Bibliography
1. [How to Read a Book (1972)](/books/how-to-read-a-book-1972) with [Van Doren, Charles.](/authors/van-doren-charles)

And

# Van Doren, Charles. 1926-2019

### Bioraphy
American English lecturer, disgraced game-show personality and writer.

### Education
* B.A. Liberal Arts - St John's College, Annapolis, MA
* M.A. Astrophysics - Columia University, NY, NY
* Ph.D. English - Columbia University, NY, NY

### Read Bibliography
1. [How to Read a Book (1972)](/books/how-to-read-a-book-1972) with [Adler, Mortimer J.](/authors/adler-mortimer-j)

And the new book file:

---
title: "How to Read a Book"
pubyear: "1972"
authors: ["Adler, Mortimer J", "Van Doren, Charles"]
subjects: ["self-improvement", "studying", "reading"]
---
# How to Read a Book (1972)

## Overview
* Authors: [Adler, Mortimer J](/authors/adler-mortimer-j); [Van Doren, Charles](/authors/van-doren-charles)
* Published: 1972
* Format: Paperback
* ISBN13: 9780671212094

## Summary
A detailed treatise on how to effectively read any type of book. Excellent points but long-winded from the mid-point on. Fantastic reading list in Appendix A.

## Key Ideas
* Reading takes conscious effort
* There are 4 stages of reading
	* Elementary - Cursory look
	* Inspectional - Skimming
	* Analytical - Detailed analysis
	* Syntopical - Reading several books on a topic
* Make notes
* The reader bears as much responsibility as the author
* Criticism can only follow understanding
* Knowledge is commulative
* You must read books that challenge you

I’ve cloned the repository and I am not able to reproduce this problem.

Even if you restart the server?

Yes, even if I restart the server. Perhaps the repository I cloned isn’t up-to-date?

Nope, not a browser issue. I built the public site with hugo -D and the resultant files aren’t correct. The van-doren-charles rendered as a list.

<!doctype html>
<html lang="en">
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<meta name="generator" content="Hugo 0.83.1" />
	<link rel="stylesheet" href="/css/bootstrap.min.css">
	<link rel="stylesheet" href="/css/main.css">
	<title>Van Doren, Charles | dtjohnst&#39;s site</title>
</head>
	<body>
		<div id="nav-border" class="container">
	<nav id="nav" class="nav justify-content-end">
		<a class="nav-link" href="/">Index</a>
		<a class="nav-link" href="/books/">Books</a>
	</nav>
</div>
		<div class="container">
			<main id="main">
<h2 class="text-center">Van Doren, Charles</h2>
<p>
	<a class="font-125" href="/books/how-to-read-a-book-1972/">Why is this a list?</a>
	<br>
</p>
			</main>
		</div>
	</body>
</html>

And the repo is indeed up to date:

git status
On branch master
Your branch is up to date with 'origin/master'.

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	public/

nothing added to commit but untracked files present (use "git add" to track)

And I’m using the latest version of Hugo as well:

hugo v0.83.1+extended linux/amd64 BuildDate=unknown

EDIT: Tried a rebuild again, and as promised, it’s randomly changed. Now adler is a list, though it wasn’t before, and this time van doren is correct.

<!doctype html>
<html lang="en">
	<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
	<meta name="generator" content="Hugo 0.83.1" />
	<link rel="stylesheet" href="/css/bootstrap.min.css">
	<link rel="stylesheet" href="/css/main.css">
	<title>Adler, Mortimer J | dtjohnst&#39;s site</title>
</head>
	<body>
		<div id="nav-border" class="container">
	<nav id="nav" class="nav justify-content-end">
		<a class="nav-link" href="/">Index</a>
		<a class="nav-link" href="/books/">Books</a>
	</nav>
</div>
		<div class="container">
			<main id="main">
<h2 class="text-center">Adler, Mortimer J</h2>
<p>
	<a class="font-125" href="/books/how-to-read-a-book-1972/">Why is this a list?</a>
	<br>
</p>
			</main>
		</div>
	</body>
</html>

And on a 3rd rebuild, both of them are lists. 4th rebuild, only adler is. 5th, still only adler. It really does seem random to me.

You have a conflict between content types and taxonomies.

You have this:

content
├── authors/
│   ├── adler-mortimer-j.md
│   ├── author1.md
│   ├── author2.md
│   └── van-doren-charles.md
├── books/
│   ├── book1.md
│   └── how-to-read-a-book-1972.md
└── _index.md

And this:

[taxonomies]
tag = "tags"
author = "authors"
book = "books"
subject = "subjects"

Your objective is unclear to me.

2 Likes

I had initially taken a different tack and hadn’t thought about it. Removing the author and book taxnomies appears to have resolved it! Thanks for your help.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.