DEV Community

Cover image for Static 2 level menu in Go
Go4WebDev
Go4WebDev

Posted on

Static 2 level menu in Go

Navigation in General
When it comes to designing navigation menus, it's generally recommended to keep the levels of depth to a minimum for optimal user-friendliness.

In my experience, a maximum of two levels deep provides a user-friendly navigation experience and reduces the chances of confusion or getting lost.

A mobile-first approach ensures that the navigation remains user-friendly across different devices and screen sizes.

Using Go HTML Templates
By using Go HTML templates, you can simplify the process of creating navigation menus. Go templates are a powerful feature of the Go language that allows for the creation of HTML pages.

Instead of hard-coding navigation elements into each individual page, you can define a single navigation sub-template that is shared across the entire site.

Go templates provide many functions that enhance the flexibility of navigation implementation. Templating functions like "if" enable you to conditionally render navigation elements based on parameters.

In this micro guide, I will show you how I created a static two-level menu navigation using Go templates.

Top comments (0)

👋 Kindness is contagious

Dive into this thoughtful article, cherished within the supportive DEV Community. Coders of every background are encouraged to share and grow our collective expertise.

A genuine "thank you" can brighten someone’s day—drop your appreciation in the comments below!

On DEV, sharing knowledge smooths our journey and strengthens our community bonds. Found value here? A quick thank you to the author makes a big difference.

Okay