Spin up a simple web server from Emacs

Before I converted my website over to WordPress, I was generating the HTML files from Org mode. First of all, this was awesome. And honestly, I would prefer to do it that way, but WordPress has a few nice publishing features that (at the time, at least) I could not emulate in Org.

One of the things that helped tremendously with the local development of my HTML site was being able to spin up a simple HTTP server right in Emacs. That’s what we’re going to be demonstrating here using the simple-httpd package.

How to install simple-httpd

You can download the Lisp code directly from GitHub, or, even more easily, install the package from the Melpa archive. You can use the package-install function in Emacs if you have already included Melpa in your list of package archives.

Here is the use-package declaration I have in my config file:

(use-package simple-httpd :ensure t)

I presume most of my readers already know how to install packages in Emacs, but if anyone would like a post about that, or more information, leave a comment below.

Spin up the server in a directory

If you already have a directory containing HTML files, then you are well ahead of me here, and you are ready to spin up your server.

I’ll use my old website as an example. I had one directory called “website” containing an “org” subdirectory for the Org Mode files, and an “html” directory for the exported HTML files. Pretty simple.

So after using the Org publish function to create the HTML files, I would just use dired to open that HTML directory, and use the httpd-start function, invoked by M-x.

Likewise, you can use the httpd-serve-directory function to be prompted for a filepath. Just put in your file path, and you will be serving that directory instead.

Your website will be served on your localhost, port 8080 by default: http://localhost:8080/


That’s it! You have completed this most important tutorial. If you have any comments or questions, be sure to let me know below. And if you dig this sort of thing, you can subscribe to my site right here:




Be the first to comment

Leave a Reply

Your email address will not be published.


*