Build Websites with Hugo
Fast Web Development with Markdown
by Brian P. Hogan
Version: P1.0 (May 2020)
Copyright 2020 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copy with other members of your team, with friends, or via file sharing services. Thanks.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
About the Pragmatic Bookshelf
The Pragmatic Bookshelf is an agile publishing company. Were here because we want to improve the lives of developers. We do this by creating timely, practical titles, written by programmers for programmers.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
Our ebooks do not contain any Digital Restrictions Management, and have always been DRM-free. We pioneered the beta book concept, where you can purchase and read a book while its still being written, and provide feedback to the author to help make a better book for everyone. Free resources for all purchasers include source code downloads (if applicable), errata and discussion forums, all available on the book's home page at pragprog.com. Were here to make your life easier.
New Book Announcements
Want to keep up on our latest titles and announcements, and occasional special offers? Just create an account on pragprog.com (an email address and a password is all it takes) and select the checkbox to receive newsletters. You can also follow us on twitter as @pragprog.
About Ebook Formats
If you buy directly from pragprog.com, you get ebooks in all available formats for one price. You can synch your ebooks amongst all your devices (including iPhone/iPad, Android, laptops, etc.) via Dropbox. You get free updates for the life of the edition. And, of course, you can always come back and re-download your books when needed. Ebooks bought from the Amazon Kindle store are subject to Amazon's polices. Limitations in Amazon's file format may cause ebooks to display differently on different devices. For more information, please see our FAQ at pragprog.com/frequently-asked-questions/ebooks. To learn more about this book and access the free resources, go to https://pragprog.com/book/bhhugo, the book's homepage.
Thanks for your continued support,
Andy Hunt
The Pragmatic Programmers
The team that produced this book includes: Andy Hunt (Publisher) Janet Furlow (VP of Operations) Dave Rankin (Executive Editor) Tammy Coron (Development Editor) Jasmine Kwityn (Copy Editor) Potomac Indexing, LLC (Indexing) Gilson Graphics (Layout)
For customer support, please contact .
For international rights, please contact .
Table of Contents
Copyright 2020, The Pragmatic Bookshelf.
Early praise for Build Websites with Hugo
I loved learning Hugo by building a real site from the ground up. Well-thought-out exercises at the end of each chapter ensure you master the material. If you run a website or blog and want to make it simpler, faster, and more flexible, then you need to read this book.
Kieran Tully |
Solution Architect, Mastercard |
Absolute guide for getting started on Hugo, and for learning how to build your next amazing website. A must read for documentation experts and technical writers looking to add power to their documentation website.
Aleemullah Samiullah |
Senior Engineering Specialist, Software AG |
There are so many introductions and tutorials out there about bringing a website online with WordPress, but Build Websites with Hugo is the introduction you need to get going fastwithout a lot of overhead. Brian gives you the tools to start crafting something and sparks your creativity, making you want to create a fast, stylish, static site with Hugo. By the end of this book, Hugo will go from being a stranger to being one of your best friends.
Dan Sarauer |
Computer Support Supervisor, City of Eau Claire |
Acknowledgments
First off, this book wouldnt be possible without Hugo itself, which is a result of the fantasic work of the Hugo team. Thank you Bjrn Erik Pedersen, Steve Francia, and all of the other amazing people whove contributed to Hugo. Thanks to your work, making things on the web is fun again, and Im excited to share the joy that Hugo brings to everyone who reads this book.
Thank you Tammy Coron for editing this book and keeping me on track. And for asking some pretty great questions when I failed to explain some things.
Thank you Andy Hunt for publishing this book.
Thank you Dan Kacenjar, Greg Myers, Ryan Palo, Aleem Samiullah, Dan Sarauer, Kieran Tully, and Stephen Wolff, for reviewing the draft of this book and catching errors before the general public would have. I wrote this book in chunks, and many pieces got moved around. Your keen eyes caught many places where inconsistencies crept in. Without your help, readers would have gotten confused or stuck in more than a few places.
Thank you to my business associates Mitch Bullard, Jeff Carley, Kevin Gisi, Alex Henry, Jeff Holland, Chris Johnson, Jon Kinney, Nick LaMuro, Myles Steinhauser, Jessica Stodola, Charley Stran, Josh Swan, Erich Tesky, Mitchell Volk, Chris Warren, Mike Weber, and Andrew Vahey for your continued support.
Thank you Lisa and Ana for inspiring me. Thank you Carissa, for your love and support, and for all you do for our family.
Copyright 2020, The Pragmatic Bookshelf.
Preface
Are you using a database to serve content that rarely changes? If youre using WordPress, Ghost, or other solutions for your content site, you probably are. Or at best, youve set up caching strategies to speed things up and reduce database calls.
Database-driven content management systems like WordPress let you define a common theme shared across your site, making it a breeze to publish new content. However, since most content doesnt change in real time, youre sacrificing speed and scalability for features that benefit content creators and developers instead of the people who want to read your content. And that additional complexity means you need more resources in production too: more servers to handle the traffic, standby database servers, a caching layer you have to manage, and more.
Theres no better way to make a snappy content site than by serving static pages from a traditional web server or a content delivery network (CDN). But you dont have to give up the rapid development features youve come to expect. Static site generators, like Hugo, give you a fantastic middle ground. You get the theming and content management features of a database-driven site without the bloat, security vulnerabilities, or complexities associated with caching.