So what I want to do is create an about page that does not show up in the index like all the other pages do when you use{{ range.pages}} for your index page. I want the about to be in a separate place on the index page. like in a nav bar. I’ve tried to create one but it still shows up like any other post.md file, but my link did show up more like expected but when I clicked on that link it says 404
github repo is here if you would like to look. Any help would be appreciated. Thanks
Normally folks don’t range through all their pages, and they keep content in sections. So, if you want your blog posts to show, you put them all in posts
or blog
, and then range over that section.
I would avoid keeping files directly in content
, and a popular practice is to have a section for so-called evergreen pages, such as your about page (you rarely update it, unlike the blog which is always changing). My suggestion: creates content/pages
, and in the about.md
front matter set the URL to what you want.
After reading over the docs info I get the idea of what the structure should be, but how do you range over just the posts folder. It’s no problem to create separate directories for separate content but how do get at it afterwards.
{{ range where .Pages "Section" "posts" }}
Figured it was something like that but couldn’t find it exactly while reading. So .pages calls the .md files in the"section (like posts)" so that it calls just the pages in that folder?
Yes. You should run it for yourself and see what happens.
OK not working quite like expected. When I put in – {{range where .Pages “content” “posts”}} it gives a big long error code that basically says -> error calling where: content isn’t a field of struct type *hugolib.Page I’ve tried several variations of this and still haven’t figured out what is going on. Found a doc that set up one like this
{{range .Pages}}
{{.Render “posts”}}
{{end}}
now this called all the posts as before but it also called the about folder too which is what I was trying to avoid.
This is different than my reply
OK learning here. So in this case range where .Pages “section” “posts”
range=> calls it to look through all pages
where=> is like your telling it to look for something
.Pages =>is telling you to look through content folder pages
“section” => is telling it where to look ie. “title” look at meta data title(?)
“posts” => is telling what it’s looking for in title meta data(?)
that is what I saw on my end. did find the doc that showed exactly what your talking about also. which is what i’m trying to figure out
got it! Did not add the “About” in title instead had “about” Need to watch my typing!
So posts
is a Section
getting my github account updated to reflect my changes and you can see.
Updated For changes
Adding the separate folders has caused a problem in github that is not showing up when using local host. When I used it in github all my links to my posts went away, but in local host t hey are still there.
The range
statement on your index template is incorrect https://github.com/prophoss/my_new_site/blob/master/layouts/_default/index.html
yeah sorry was changing things to try and get it to work with no luck. Put it back in order. Will come back to this tomorrow.