O'Reilly logo

Working with Static Sites by Brian Rinaldi, Raymond Camden

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. Adding Dynamic Elements

Now  that you’ve made the decision to use a static site generator (woo!), you may discover that you’ve forgotten one little detail that seems to require a dynamic application server of some sort. Perhaps you have a contact form. Maybe you want to add discussions to your blog. Does this mean you’ve made a horrible mistake and have to revert everything you worked on? Of course not!

Multiple different services exist that enable you to add dynamic features back to your site. In some cases, it is nearly impossible for the end user to tell that anything “special” is being done at all. To them, it simply appears as if your site is doing whatever it needs to on the backend, when in reality you’re still using simple static files.

In this chapter, we’ll discuss how to add dynamic elements back in to your static site. We’ll focus on:

  • Forms
  • Comments
  • Search

We’ll also discuss some other options for data types, like events and generic sets of data.

Handling Forms

Since the dawn of the web itself, forms have been an integral part of how users interact with your site. Moving to a static site doesn’t make forms themselves magically stop working. They still render. You can still interact with them using JavaScript. But if you want the form to do something on a server or to communicate with someone else, then you’ll be out of a luck when using a static site. Luckily, a number of options exist for adding basic form processing to your site. Let’s ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required