Failed to render pages: render of "page" failed: execute of template failed: template: _default/single.html:7:11: executing "main" at <partial "breadcrumbs.html" .>: error calling partial: "/Users/my-project/themes/hugo-theme/layouts/partials/breadcrumbs.html:1:19": execute of template failed: template: partials/breadcrumbs.html:1:19: executing "partials/breadcrumbs.html" at <.Ancestors.Reverse>: can't evaluate field Ancestors in type *hugolib.pageState
Ok, I updated Hugo to the latest version and the solution partially works. This means that I don’t get errors anymore but there are some issues in the breadcrumb itself now. The folder structure for one of the files is like this:
@jmooring thanks again for the answer. Your answer for the website-name resolved that issue.
But for the second part, which was why folder2 is not shown in the breadcrumb I did what you mentioned and I have a new problem. Let me explain.
The files and folder structure for my website are something like this:
As can be seen under the content folder I have a file called folder1.md and a folder called folder1. The file folder1.md contains links to folder2, folder3, etc.
And under folder1 I have a few folders and for each folder, I have a file with the same name. For example, under folder1 I have folder2 as a folder and folder2.md, etc.
Finally, under folder2 I have some files like file1.md etc.
So to me, there is no difference between folder1 and folder2. Why folder1 is shown in the breadcrum, but folder2 is not shown?
If I do what @jmooring recommended, which is hugo new folder1/folder2/_index.md then when I am on folder1.md and click on a link to go to folder2 I get a message that says Page Not Found.
Is this because I don’t have a correct file and folder structure?
Does the breadcrumbs.html code work for any folder depth? Or it only works for one level depth of folders?
Your content structure is incorrect. If you want directory to be a logical section, it must contain an _index.md file (a section file). The section file can contain content, just like any other page, but its template will typically range through the child (not descendant) pages.
@jmooring looking at the content structure you have shown above, currently for example for product-1 folder instead of _index.md, I have product-1.md. Should I transfer the content of product-1.md to _index.md and remove product-1.md. And do the same for benefits and features, etc.?
@jmooring Thanks so much for the example.
I have mine implemented similar to your example page.
However, on my main page, I have a link to products. When I click on that link the url on the web-browser changes to: http://localhost:1313/products/ but then I get the Page Not Found error message. In my website I have another folder parallel to products, let’s call it tools and I have this structure for that:
and in the main page I have a link to tools as well. When I click on that link it correctly goes to http://localhost:1313/tools/ and shows the content of tools.md.
For both of them in the config.toml I have this that shows a link to them in the main menue:
# Navigation Bar
name = "Home"
url = "#home"
weight = 1
name = "Products"
url = "/products"
weight = 2
name = "Tools"
url = "/tools"
weight = 3
Do you see I am doing something wrong? As I changed the content structure for products from:
Hugo does not clear the public directory before building your site. Existing files are overwritten, but not deleted. This behavior is intentional to prevent the inadvertent removal of files that you may have added to the public directory after the build.
Depending on your needs, you may wish to manually clear the contents of the public directory before every build.
If you need further assistance, please post a link to the public repository for your project.
Include a link to the source code repository of your project, because we really need the context of seeing your templates and partials to be able to help you. It is trivial to do a quick git clone on your repo, then run hugo server in your project, to help you out. On the other hand, recreating your code from screenshots, or sort of guessing at it, is not.
If you can’t share your repository for whatever reason, consider creating a dummy repo that you can share, which reproduces the problem you’re experiencing.