# Multilevelmenu without drafts from config.toml

**URL:** <https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377>\
**Category:** support\
**Created:** [March 4, 2019, 2:09pm UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377 "2019-03-04T14:09:12Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![georgkaser](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/georgkaser/32/8022_2.png) [@georgkaser](https://discourse.gohugo.io/u/georgkaser)\
**Post date:** [March 4, 2019, 2:09pm UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/1 "2019-03-04T14:09:12Z")

</div>

Hi,  
I have some problems to render my navigation without drafts. Is there an easy example snippet somewhere to understand why drafts are always rendered?

Or whats wrong with my code?

```
<ul class="nav-vertical first-level">
	{{ $currentPage := . }}
	{{ range .Site.Menus.main }}
		{{ if .HasChildren }}
			<li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}">
				<a href="{{ .URL }}">{{ .Name }}</a>
				<ul class="second-level">
				{{ range .Children }}
					<li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}">
						// here the link
					</li>
				{{ end }}
				</ul>
			</li>
		{{ else }}
			<li class="{{ if $currentPage.HasMenuCurrent "main" . }}active{{ end }}">
				// here the link
			</li>
		{{ end }}
	{{ end }}
</ul>
```

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [March 4, 2019, 2:40pm UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/2 "2019-03-04T14:40:54Z")

</div>

Hi,

How are you running Hugo? Running `hugo` or `hugo server` with the `-D` or `--buildDrafts` flag will [include draft content](https://gohugo.io/getting-started/usage/#draft-future-and-expired-content).

---

<div class="post-metadata">

**Author:** ![georgkaser](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/georgkaser/32/8022_2.png) [@georgkaser](https://discourse.gohugo.io/u/georgkaser)\
**Post date:** [March 4, 2019, 4:50pm UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/3 "2019-03-04T16:50:55Z")

</div>

I tested it with and without -D - I do it that way:

```
hugo server --disableFastRender
```

---

<div class="post-metadata">

**Author:** ![pointyfar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/pointyfar/32/5797_2.png) [@pointyfar](https://discourse.gohugo.io/u/pointyfar)\
**Post date:** [March 5, 2019, 9:26am UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/4 "2019-03-05T09:26:04Z")

</div>

Hi,

In that case, we probably need to see more of your code to help you troubleshoot. Do you have your code somewhere we can look at?

---

<div class="post-metadata">

**Author:** ![georgkaser](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/georgkaser/32/8022_2.png) [@georgkaser](https://discourse.gohugo.io/u/georgkaser)\
**Post date:** [March 5, 2019, 2:07pm UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/5 "2019-03-05T14:07:56Z")

</div>

Thank you, I uploaded it on my git server for you: [https://git.georgkaser.com/georgkaser/my-hugo-project/tree/master](https://git.georgkaser.com/georgkaser/my-hugo-project/tree/master) so you can browse the code…

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [March 5, 2019, 4:48pm UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/6 "2019-03-05T16:48:44Z")

</div>

You added those items to the `main` menu from your `config.toml`. Since those menu items aren’t from pages, ~~they aren’t affected by the `range`, hence the confusion.~~ … sorry, I mistyped there.

When you are `range` over the main menu, it gets all the menu items. Then, you start filtering them by conditionals, but the items you set in your config aren’t included, hence the reason they show up at all times.

You’ll have to re-think how you build that menu. 🙂

---

<div class="post-metadata">

**Author:** ![georgkaser](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/georgkaser/32/8022_2.png) [@georgkaser](https://discourse.gohugo.io/u/georgkaser)\
**Post date:** [March 5, 2019, 10:19pm UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/7 "2019-03-05T22:19:39Z")

</div>

So, i have to generate the menu from the pages instead of the config.toml?

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [March 5, 2019, 10:38pm UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/8 "2019-03-05T22:38:17Z")

</div>

I’m not sure what you are trying to do. Aside from the draft status of the items in question, the menu looks good. The original question was about draft status, and we know that isn’t the issue, so could you clarify what you are trying to do?

---

<div class="post-metadata">

**Author:** ![georgkaser](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/georgkaser/32/8022_2.png) [@georgkaser](https://discourse.gohugo.io/u/georgkaser)\
**Post date:** [March 7, 2019, 10:31pm UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/9 "2019-03-07T22:31:20Z")

</div>

Thank you for your help - I thought that the draft status is considered when I create the menu from config.toml - this is not the case, isn’t it?  
I read now the docs and I think I should try to create the menu from front matter.

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [March 8, 2019, 12:17am UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/10 "2019-03-08T00:17:45Z")

</div>

> [@georgkaser](#):
>
> this is not the case, isn’t it?

It is not the case. And that is useful, because you can add **any** links to the menu from config. You could put your email as a menu item, or link to other sites you run. That sort of thing.

For draft status, yeah, go with front matter. 🙂

---

<div class="post-metadata">

**Author:** ![georgkaser](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/georgkaser/32/8022_2.png) [@georgkaser](https://discourse.gohugo.io/u/georgkaser)\
**Post date:** [March 8, 2019, 8:38am UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/11 "2019-03-08T08:38:37Z")

</div>

I understand, thanks for your help!

---

<div class="post-metadata">

**Author:** ![georgkaser](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/georgkaser/32/8022_2.png) [@georgkaser](https://discourse.gohugo.io/u/georgkaser)\
**Post date:** [March 8, 2019, 1:52pm UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/12 "2019-03-08T13:52:44Z")

</div>

Hmm, it’s not that easy. I think i didn’t understand some concepts of rendering menus and managing content. I created a new theme for testing purposes - just for the menu. And the output was not what I expected.

Look at that screenshot - why is it not possible to render the content with subcontent as unordered list??

 ![Screenshot-08-03-2019_14-45](https://canada1.discourse-cdn.com/flex036/uploads/gohugo/original/2X/8/848271f26cf94314aa30201eb63b6a1089ee177e.png)

---

<div class="post-metadata">

**Author:** ![maiki](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.gohugo.io/maiki/32/16384_2.png) [@maiki](https://discourse.gohugo.io/u/maiki)\
**Post date:** [March 9, 2019, 12:03am UTC](https://discourse.gohugo.io/t/multilevelmenu-without-drafts-from-config-toml/17377/13 "2019-03-09T00:03:05Z")

</div>

> [@georgkaser](#):
>
> Look at that screenshot - why is it not possible to render the content with subcontent as unordered list??

That’s not how we do it here: share your code. Presume I can’t see your screenshot.
