This chapter covers:
- Building custom pages in Hugo.
- Rendering content and accessing variables and functions in the Go Template language.
- Accessing Hugo’s configuration and front matter in code.
- Reading from the filesystem using Hugo.
- Creating custom shortcodes
- Create reusable page templates called archetypes
One strength of Hugo is a clear separation of concerns between content (markdown) and presentation (HTML/CSS/JavaScript). While creating content we rarely have to deal with HTML. Team members who are not well versed in HTML/CSS can be successful with Hugo as a content management system using features we discussed so far in this book. A lot more power can be unlocked in going one layer deeper into the layouts and HTML generation. In chapter 2 we have stepped out of the theme to create the home page in pure HTML. In doing so, we eschewed the role of the content creator and went into the web developer mode while mostly supplying content for the other pages. In this chapter we will get first-hand experience with Hugo’s template language, its rendering mechanism as we improve the home page of the Acme Corporation website and add some features which are based on the content which a static HTML page cannot provide.
The pure HTML index page we currently have for the Acme Corporation website has intermingling of content and layout. This approach has a huge set of problems: