Skip to content

grumpygamer/static-hugo-comments

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

A single PHP file that allows comments on a static blog.

The blog must be served by a web server that understands PHP so this isn't suitable for pure static delivery like a S3 bucket.

It's been tested on Apache, but should work on other webservers.

It's been tested on HUGO, but probably works on other static sites.

To install, copy comments.php to the static folder of your HUGO site.

Also add this to an .htaccess file in the static directory. Create if it doesn't exist.

AddHandler application/x-httpd-php .html

In the single.html HUGO file add the following after the .Content is output.

{{ if .Params.comments }}
  {{ safeHTML "<?php require $_SERVER['DOCUMENT_ROOT'] . '/comments.php'; ?>" }}
{{ end }}

The post must have this header for entries that you wish to show comments.

comments: true

You may need to install the following PHP extensions.

Examples for Ubuntu

sudo apt install php-curl
sudo apt install php-sqlite3
sudo apt install php-mbstring

There are also several defines at the top of comments.php for customizations like captcha and notifying Discord of new comments.

Comments can be stored in a Sqlite database or on disk as flat files. 4 out of 5 doctors recommend Sqlite.

About

Add comments to a static website such as hugo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages