I’m relatively new to Hugo and trying to decipher how I can create a standalone page when using the Tale theme like the tags page in the demo, i.e. a page that is linked from the header, doesn’t show up in the posts list, and doesn’t have an author reference at the top saying “Written by…”. Looking through the files for the theme, I don’t understand how the tags page is generated. My ultimate goal is to add a standalone page with a list of my publications that is linked to from the header of the site. I’d appreciate any pointers you all may be able to offer!
doesn’t have an author reference at the top saying “Written by…”
In Hugo, there are templates for different types of content. Each type may have its own template for lists, standalone, etc. We can also create template for custom types.
For this example, we can create a custom archive type by creating layouts/archive. Since you want a standalone page, we’ll create a single page template at layouts/archive/single.html. For reference, here’s how I implement it. Then, in one of the content, I’ll simply declare the content to be of the archive type and Hugo will render the page as declared from layouts/archive/single.html.
Hope that explains it. Still, feel free to ask a question if it’s unclear. Hugo is a huge software, after all.
Thank you @foo-dogsquared for your thorough reply! So here’s exactly what I did that failed to change anything. In layouts/single I created list.html with the following content:
<h1>{{ .Title }}</h1>
{{ .Content }}
I then created the file content/contact.md with the following content:
---
title: "Contact"
type: "single"
menu: "main"
---
This is a test.
And sadly this page is still rendering as a blog post with the same formatting I mentioned in my first post. It’s almost as if the type declaration is not registering. So baffling. Any suggestions?
Just to clarify, are you suggesting changing the type to type: "list" in the front matter? I just tried that and the page still shows up in the blog post list.
thank you sir! that actually solved the major problem of removing the page from the blog post list. now to figure out how to remove the “Written by…” addition to the page.
post a link to the repo with the layouts and I ask my texteditor to search for those words
Do you know that you can override single template files by having a copy of them in your root/layouts folder? Let’s say there is a /themes/mytheme/layouts/_default/single.html in your theme folder, then copy that into /layouts/_default/single.html in the root directory of your website repository and change things in that file. Hugo will prefer those files.
So what you do is look for “Written by…” in your theme, copy the file, remove the line.
I’ve been grepping on the themes directory looking for the origin of this.
The “Written by” bit only shows up in a .toml file. I need to keep tracing back to find out where it shows up in a layout.
I do know about the layout override thankfully. I’m clearly managing to get that to work. As you are pointing to, the last bit of the puzzle is to figure out how that page is currently being rendered and remove the unwanted contribution. I’ll keep digging. I greatly appreciate your pointers!
So I found where it shows up. Your suggestion is exactly what I tried. How should I think partials in the layouts? I assume these are page sections? I’ll keep grepping…
yes sir. I’ll try this now. what I’m suspecting though is that this will remove the author name addition from all my blog posts as well. I’m aiming just to remove it from the static pages I add. so I’m thinking I need a new page type.
Define “static page”. Is that all “not blog pages”? You can check in that template if you are in the blog section or not before adding the lines. What is your blog “section” called? (The foldername of your blog entries inside of content.)
Now any static page placed in content with the front matter:
—
type: “staticpage”
_build:
list: never
menu: “main”
—
yields a static page that is not listed in the blog post list, is linked from the header of the blog, and does not have an another reference.