💾 Archived View for cadence.moe › bliz-documentation › 02-static-content.gmi captured on 2022-03-01 at 15:02:52. Gemini links have been rewritten to link to archived content

View Raw

More Information

-=-=-=-=-=-=-

Bliz documentation: Static content

Serving static content couldn't be easier with Bliz.

Serving a file

Put the file into `serve/` and it's available on the Gemini protocol.

For example, saving to `serve/demo-file.gmi` would allow you to access `gemini://localhost:1965/demo-file.gmi` and see the file.

Supported types

Gemini's native text type is called "gemtext", mime type text/gemini, with file extension .gmi. Bliz supports gemtext, as well as every other file type.

For most files, the command-line tool `file` is used to detect that file's mime type based on its content (not based on its extension). However, the type text/gemini isn't official and isn't in the `file` database. So for gemtext, you do have to save it in a .gmi file.

Serving a folder

By default, accessing a folder displays a listing of all the files in it. Helpful!

Trailing slashes

If the URL to a folder doesn't have a trailing slash (e.g. /gemlog), Bliz will redirect the visitor to a version with a trailing slash (i.e. /gemlog/).

Whenever you write links to directories, I suggest that you manually include the trailing slash for two reasons.

But if you forget to include it, it's not the end of the world. The visitor will just be redirected and then see the page.

Why is a redirect necessary?

(aka, why not generate the response directly on /blog?)

Because relative links on the page would be broken.

Links in the same document would lead to different places if a visitor accesses the document in a slightly different way!

Redirecting to a canonical version of the directory URL, with a trailing slash, is best for everyone.

Using index pages with folders

Some other servers support `index.gmi` files that will be displayed instead of the directory listing when somebody accesses a folder.

Bliz supports these too - you just have to enable it. Edit the file `personal/config.fish` and add this line:

set serve_index index.bliz index.gmi

This creates a variable `serve_index` which is a list with two elements: `index.bliz` and `index.gmi`.

When somebody loads a directory, Bliz will check if those files exist in that directory. If one of those files exists, it will be displayed. If none of those files exist, then the person will see the directory listing as usual.

(The index page doesn't have to be a text file. You can put things like images there if you want to! Just make sure the filename of that image is in the variable `serve_index`.)

Next page: .bliz scripting

Back to documentation index