Importing static content

This is a technique I’ve been using on my own blog, but I don’t think it’s well documented anywhere. If you ever have a bunch of arbitrary static files, perhaps from a legacy web site, you can import them into a blog via a custom plug-in. Plug-ins don’t need any code or JSON. They can just act as containers.

Let’s say I have a folder called “old-files” that has its own sub-folders, HTML files, images, whatever. Here’s how to get that onto your blog:

  1. Create a GitHub repository. This is the technical part but the rest of the steps are easy.
  2. In the repository, create a folder called “static”. Hugo uses this special folder name to store files that aren’t processed by templates or other code.
  3. In the “static” folder, add your “old-files” folder or whatever you want.
  4. In Micro.blog, click on Design → Edit Custom Themes → New Plug-in.
  5. Enter the URL for the GitHub repository. You can give the plug-in any name, it’s just for your own purpose.
  6. Micro.blog will download the files from GitHub and store them so they are always published to your blog along with any other content.

So in our above example, we’ll now have URLs on our blog like myblog.com/old-files/somefile.txt.

Note that there are probably limits to this. It’s designed for a fairly small number of files. I would not try to import hundreds of megabytes of data this way, because that could slow down your blog publishing. Photos and videos are best uploaded directly to Micro.blog because they can be served faster with the CDN.

In the future it probably makes sense to have a “folder upload” feature to bypass the GitHub step, but hopefully the solution outlined above is a good work-around for folks who need it.

4 Likes