Menu

RTCXpression

Close

Add Forms and a Comment Section to a Static Website or Blog

- April 27, 2017

forms The one drawback of a static website is that it’s not capable of user interaction on its own. You can’t have forms or a comment section unless you use a third-party service.

Fortunately, there are reliable third-party services that won’t cost you any money to add and use on a static website. I used to avoid these services but I won’t anymore. It’s a lot easier to use these services than it is to create custom code to do the same things.

I’m going to tell you about two services I use and how to make them work right without a lot of hassle.

Disqus for the Comment Section

There are other services like it, but I’ve only used Disqus. If you scroll down and click on the button that says “View Comments”, you can view existing comments (if any) or post new comments.

There’s a lot of code floating around and I use this code:

<div id="disqus_thread">
  <div style="text-align:center;"><button onclick="disqus();return false;" style="margin-bottom:20px;margin-top:20px;">View Comments</button></div>
</div>
<script>
var disqus_url = "https://www.rtcx.net/this-post.html";
var discus_identifier = "[post ID] https://www.rtcx.net/?p=[post ID]";
var discus_title = "[post title]";
var disqus_loaded = false;
function disqus() {
  if (!disqus_loaded)  {
    disqus_loaded = true;
    var e = document.createElement("script");
    e.type = "text/javascript";
    e.async = true;
    e.src = "//rtcxpression.disqus.com/embed.js";
    e.setAttribute("data-timestamp", +new Date());
    (document.getElementsByTagName("head")[0] ||
     document.getElementsByTagName("body")[0])
    .appendChild(e);
  }
}
</script>

The “var discus_identifier” is a holdover from WordPress. As long as you can uniquely identify each page, you can use almost anything.

The reason I like this code is that Disqus doesn’t load until you click that button. Most people won’t and that keeps the website running smooth and fast.




Google Forms for all the Forms

I’ve known about Google Forms for a while but I just recently started using them. Today, I changed the existing form on my contact page with a Google form.

You can play with the appearance but you’re limited to what’s available. In the settings (clicking on the gear icon), make sure you uncheck “Limit to 1 response” so that a non-Google user can have access to the form.

It would also make sense to edit the confirmation message. On the response tab of the form (as you work on it), you can check the option to get an email notification when someone submits the form.

The width in the iframe code must be changed to “100%” to make the form responsive. The height must be changed to “960” to keep the right scroll bar from appearing.

You’re welcome to test the form on my contact page. I’ll reply to it if it seems like I should. If you don’t want a reply, please tell me.

No Need for PHP or a Database

A static website shouldn’t need to have PHP available. Using a database defeats the purpose of a static website. I no longer run PHP or MySQL on my server and I have a 100 percent static website as of today.

I’m comfortable knowing I can create more forms, if necessary. I’m also comfortable knowing that my website can’t get hacked from the outside and I’m the only person with access to the inside.

Share:

Facebook Twitter Google+

Subscribe:

E-Mail, RSS Feed

Categories:

Technology

Previous and Next Articles:

« »

Comments:

Your comment will appear below the form when it's approved. When the page redisplays after hitting the send button (it can take a few seconds), your comment has been sent.

When replying to someone else's comment, please start the comment with "@" and the name so I can put it in the right place.

Please read some of my more important pages if you have the time:

Comments Policy           Privacy Policy

RTCXpression established Feb 28, 2011
Copyright © 2013-2017 RT Cunningham
Hosted at Digital Ocean