Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sidebar not displaying content/posts/ #188

Open
mohummedalee opened this issue Jun 24, 2024 · 4 comments
Open

Sidebar not displaying content/posts/ #188

mohummedalee opened this issue Jun 24, 2024 · 4 comments

Comments

@mohummedalee
Copy link

Hi, thanks for the wonderful theme. I'm posting here to seek help with debugging an issue. This is the version I'm using: hugo v0.126.1+extended darwin/amd64 BuildDate=2024-05-15T10:42:34Z VendorInfo=brew

My webpage is currently live on https://m-ali.org (GitHub repo: https://github.com/mohummedalee/mohummedalee.github.io). As you can see, the sidebar currently has a Publications and an About page. I'm in the process of adding a blog section that would list all posts under content/posts. Here is what my config.toml looks like right now:

menu = [        
  {Name = "Publications", URL = "/publications/", HasChildren = false},
  {Name = "Blog", URL = "/posts/", HasChildren = false},
  {Name = "About", URL = "/about/", HasChildren = false},
]

And here is what the content/ directory looks like:

content
├── _index.md
├── about
│   └── _index.md
├── landing
│   └── _index.md
├── posts
│   ├── _index.md
│   └── pii-kaggle
│       └── index.md
└── publications
    └── _index.md

As you can see there is only one post (pii-kaggle). A list of posts is visible when I visit the local deployment on localhost:1313/posts/ as well as the post itself on localhost:1313/posts/pii-kaggle. But the sidebar will not display the posts folder.

Will appreciate any help debugging this, am happy to provide more info if my issue is unclear, hope the link to my repo also provides additional information.

@mohummedalee
Copy link
Author

It turns out that deleting content/posts/_index.md fixes this issue, I can now see "Blog" in the sidebar. Hope this helps someone else.

Is there a way to make this new listed page look exactly like the default home page in the theme? I'd ideally like a title, and a blurb from the post similar to the landing page here: https://karlaustin.com/. If I cannot add a markdown file under posts/, how can I style it?

Again, appreciate the help!

@mohummedalee
Copy link
Author

Figured out how to get the posts page to look like the default homepage. I simply copied layouts/index.html from the original theme and pasted it to a new file in layouts/posts/posts.html. Still not entirely clear to me how layouts are looked up, but this works for now.

I'll keep this issue open for another 1–2 weeks in case anyone has feedback, or any suggestions on best practices etc.

@Mauzy0x00
Copy link

Hey there! Learning this as I go but I found that if I just add a directory into /content/ and give the .md file a name that is anything other than 'index.md' it works.

@lemonase
Copy link

lemonase commented Mar 7, 2025

Hi, I had a similar issue with the sidebar not showing content pages

It was the about.md and /about/ for me.

Hugo version: hugo v0.145.0+extended+withdeploy linux/amd64 BuildDate=unknown

Using the default config.toml mentioned in README

menu = [
  {Name = "About", URL = "/about/", HasChildren = false},
  {Name = "Posts", URL = "/posts/", Pre = "Recent", HasChildren = true, Limit = 5},
]

Files in content/ directory

content $ ls
posts/  about.md

Here is the content/front matter for about.md

---
title: "About Me"
date: "2024-02-03"
---

Hello World
...

I should mention too, the /about/ page works fine when going directly to that URL.

Looking through the template for the sidebar:
https://github.com/lukeorth/poison/blob/master/layouts/partials/sidebar/menu.html#L4-L58

It looks like this conditional is causing the title to not get included (even though the file and config item exists)

{{ $trimmedURL := (lower (strings.TrimSuffix "/" (strings.TrimPrefix "/" $menu_item.URL))) }}
{{ if eq (lower .Title) (replace $trimmedURL "-" " ") }}

About page now shows up in the sidebar after changing this conditional.

{{ if $trimmedURL }}

Before/after pics:
https://imgur.com/a/6giPQnB

My Issue

The top level about.md in content directory does not seem to be considered a "site section" so looping
over sections will ignore that file, but having a directory like about/_index.md works:

https://github.com/lukeorth/poison/blob/master/layouts/partials/sidebar/menu.html#L4

So just to recap:

  • Top level .md content files not considered site sections per docs - use directory and _index.md.
  • .Title in your content must (case-insensitive) match to URL of menu items inside of config.toml (string.Contains may be a good option here).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants