janraasch / hugo-bearblog

🧸 A Hugo theme based on »Bear Blog«. Free, no-nonsense, super-fast blogging. This theme now includes a dark color scheme to support dark mode 🦉 ⬛️!
https://themes.gohugo.io/hugo-bearblog/
MIT License
902 stars 222 forks source link

Use *blog* as startpage #2

Closed aparcar closed 4 years ago

aparcar commented 4 years ago

I'd like to skip the usage of Home and only use the Blog feature. Is it possible to disable to Home page?

janraasch commented 4 years ago

Hi @aparcar, thank you for getting in touch 👍🏻 😄.

Is it possible to disable the Home-page?

Sure. Anything's possible with Hugo 😜 . Here's an idea:

+++
title = "Blog"
url = "/"
+++

🎸 With that, your blog posts will render directly under https://aparcar.gitlab.io.

I hope that helps.

Let me know if you have any other/follow-up questions.

Greetings to Hawaii 🌞 😄 , Jan

huyvohcmc commented 4 years ago

Hi, I have the following things:

<!-- layouts/partials/nav.html -->
<a href="{{ "/" | relURL }}">Blog</a>
<a href="{{ "/about" | relURL }}">About</a>
<!-- content/blog/_index.md -->
+++
title = "Blog"
url = "/"
+++

But my home page only show the menu of "blog" and "about", not the menu and the list of blog posts. Something I'm missing? Sorry first time Hugo.

janraasch commented 4 years ago

Hi @huyvohcmc, thank you for reaching out 😸.

I am not 100% sure what you mean by »not the menu«, but I'll outline what I think would be best. Then, feel free to provide more details on what you are trying to achieve if what I propose does not work out for you 🧑‍🏭.

So here's the deal.

The Menu

I think it would be best to use Hugo Menus.

That means your layouts/partials/nav.html will be

{{ range .Site.Menus.main }}
<a href="{{ .URL }}">{{ .Name }}</a>
{{ end }}

Then, to make any page (i.e. /content/*.md or content/blog/*.md) appear on the menu, you simply add

menu = "main"

to its frontmatter, e.g. your /content/blog/_index.md.

If you want to have more control over the ordering you can use the Weight-param. To make the Blog the first item on the menu, you could e.g. place

+++
title = "Blog"
url = "/"
[menu]
  [[menu.main]]
     weight = 0
+++

inside your /content/blog/_index.md-file.

From what you said, I'm assuming (feel free to correct otherwise 😺) you also have a /content/about.md-file which you want to place on the menu. To to do that you would add

+++
title = "About"
[menu]
  [[menu.main]]
     weight = 10
+++

to your /content/about.md-file.

The list of blog posts

With url = "/" inside your /content/blog/_index.md-file your homepage should render the list of blogposts, i.e. the list of files inside your content/blog/-folder.


I hope that helps. Let me know if it does.

Kind regards to Ho Chi Minh City, Vietnam 👋🏻, Jan

huyvohcmc commented 4 years ago

It works! Thank you @janraasch for the nice explanation.

janraasch commented 4 years ago

Sure. Have fun with your »Bear Blog« 💯 👋🏻 .

alabhyajindal commented 10 months ago

Hi!

Thanks for the great theme!

I'm having a strange problem. I followed your instructions here to use the blog list page as home. The issue is that sometimes I get a blank page on the home section and sometimes I get the blog list. It's completely random.

I don't have a content/_index.md file and my blog/_index.md contains:

+++
title = "Blog"
url = "/"
[menu]
  [menu.main]
    identifier = "blog"
    weight = 1
+++

My website is at https://alabhyajindal.com and the source code is at https://github.com/alabhyajindal/aj, if you want to take a look.

janraasch commented 10 months ago

Hi @alabhyajindal, thank you so much for reaching out, let's continue on ➡️ https://github.com/janraasch/hugo-bearblog/issues/79.