Publishing

Web server settings

Any web server can serve a HotDog site. Here are ready-to-use settings for nginx, Caddy and Apache, including shared hosting.

A HotDog site is plain files, so any web server works (How your site is served explains why). A few settings make it work well:

  • a folder's index.html is served for its address (/about/ serves about/index.html);
  • a missing page gets 404.html, with the "not found" status;
  • files with a code in their name (styles.3f9a1c2b07.css) are kept by browsers for a year, since a new version always gets a new name; pages are checked for changes every time;
  • calendar feeds (.ics) are sent as calendars;
  • HotDog's own bookkeeping files (/.hotdog-cms-…) aren't served.

nginx

server {
    listen 443 ssl;
    server_name example.org;
    root /var/www/example.org;
    index index.html;
    absolute_redirect off;

    location / {
        try_files $uri $uri/ =404;
        add_header Cache-Control "no-cache";
    }
    location ~ "\.[0-9a-f]{10}\.[A-Za-z0-9]+$" {
        add_header Cache-Control "public, max-age=31536000, immutable";
    }
    location ~ "\.ics$" { default_type "text/calendar; charset=utf-8"; }
    location ~ "^/\.hotdog-cms-" { return 404; }
    error_page 404 /404.html;
}

Caddy

example.org {
	root * /var/www/example.org
	@hashed path_regexp \.[0-9a-f]{10}\.[A-Za-z0-9]+$
	header @hashed Cache-Control "public, max-age=31536000, immutable"
	@ics path *.ics
	header @ics Content-Type "text/calendar; charset=utf-8"
	respond /.hotdog-cms-* 404
	file_server
	handle_errors {
		rewrite * /404.html
		file_server
	}
}

Apache, and shared hosting

Apache can read settings from a file called .htaccess in the site's folder. Save this as static/.htaccess in your site, and it's published with the site every time. It's also the way to do it on shared hosting, where you can't change the server's own settings.

# Settings for Apache, published with the site.
DirectoryIndex index.html
ErrorDocument 404 /404.html
AddType "text/calendar; charset=utf-8" .ics
RedirectMatch 404 "^/\.hotdog-cms-"
<IfModule mod_headers.c>
  Header set Cache-Control "no-cache"
  <FilesMatch "\.[0-9a-f]{10}\.[A-Za-z0-9]+$">
    Header set Cache-Control "public, max-age=31536000, immutable"
  </FilesMatch>
</IfModule>
  • The caching lines need Apache's mod_headers, which most hosts have. Without it, the site still works; browsers just check files more often.
  • If your server ignores .htaccess files (AllowOverride None), put the same lines inside the site's <Directory> section instead.

Caddy gets a TLS certificate for your domain by itself. With nginx or Apache, use Certbot or your host's certificates.

Redirects

Redirects from site.yaml are built as small pages that send visitors on, so they work on any web server with no settings. The finished site also lists them in a file, for publishers that turn them into web server rules.

If your site has forms, pass /_hotdog/ to the endpoint: see Forms and search on your server.