9 Accessing APIs to enhance functionality

 

This chapter covers

  • Enhancing the website using APIs
  • Embedding tweets into a web page
  • Creating forms using third-party APIs
  • Using form APIs to create dynamic forms
  • Creating a JSON-based API using Hugo’s output formats

In the first half of this book, we worked on the Hugo website in isolation. This chapter involves using Hugo to get access to data from outside of our website. We will also add dynamic features and learn how the Jamstack can perform tasks requiring server intervention without sacrificing the website’s performance.

9.1 Build-time vs. run-time API access

9.2 Embedding tweets at compile time

9.2.1 Understanding the Twitter API

9.2.2 Understanding Hugo’s functions for compile-time API access

9.2.3 Rendering a tweet as a testimonial

9.2.4 Managing content lifetimes

9.3 Hugo and REST APIs

9.4 Creating a contact page the Jamstack way

9.4.1 Setting up a contact form

9.4.2 Choosing a form provider

9.4.3 Using Netlify forms for the Contact Us page

9.4.4 Using Formspree for contact forms

9.5 Building dynamic surveys

9.6 Commenting using the Jamstack

9.6.1 Displaying a comment form

9.6.2 Displaying comments

9.7 Pseudo APIs that compile to JSON