Bump license
Use .gmi extension for gemini texts
Fixing typo, one reported by Oliver Marugg
cl-yag is a lightweight, static site generator that produces gopher sites as well as html websites. The name 'cl-yag' stands for 'Common Lisp - Yet Another website Generator'. It runs without needing Quicklisp (Common LISP library manager).
I am using cl-yag to create and maintain my websites in the world-wide-web (visit: [Solene's percent] (https://dataswamp.org/~solene/)) as well as [in gopher-space] (gopher://dataswamp.org/1/~solene/).
To use cl-yag you'll need:
Go into your project's directory and type make
. You'll find your new website/gopher page in output/.
If you want to get rid of everything in your output/ sub directories, type make clean
.
For further commands: read the Makefile.
Read in the following section where to find it.
After cloning the repository, your project's directory should contain at least the following files and folders:
.
|-- LICENSE
|-- Makefile
|-- README.md
|-- data/
| |-- 1.md
| |-- README.md
| `-- articles.lisp
|-- generator.lisp
|-- output/
| |-- gopher/
| `-- html/
|-- static/
| |-- css/style.css
| `-- img/
`-- templates/
|-- article.tpl
|-- gopher_head.tpl
|-- layout.tpl
|-- one-tag.tpl
|-- rss-item.tpl
`-- rss.tpl
And there is the data/ directory, which is important enough to get a subsubsection of its own.
This directory is crucial for the usage of cl-yag.
data/ contains
For more information: Read section 'Configuration'.
cl-yag's main configuration file is data/articles.lisp.
In order to have a running implementation of cl-yag, you have
to set most of the values in this file.
data/articles.lisp has two parts:
Values are assigned by placing a string (e.g. "foo"
) or a boolean
(i.e. t
or nil
) behind a keyword (e.g. :title
).
The config variable is used to assign the following values:
:webmaster
gets used, if :author
is omitted. (See below: 'The articles variable'.)https://mydomain/~~user/
t
to export html website. Set nil
to disable.t
to export gopher website. Set nil
to disable.Each post is declared with its meta-data using the function "post". So you need to add a new line for each of your posts.
Of the following keywords, only :author
and :short
can be omitted.
:author
field is used to display the article's author.:webmaster
field of the config variable.:id
field holds the file name of your post/page.:id "2"
will load file data/2.md. Use text instead of numbers, if you want to.:tag
field is used to create a "view" containing all articles of the same tag.:tiny
field's value is used for displaying a really short description of the posts content on your homepage.:tiny
doesn't get a value, the full article gets displayed.:tiny "Read the full article for more information."
, if you don't want to display the full text of an article on your index site.:title
field's value sets your post's title, its first headline, as well as its entry on the index.html.Edit data/articles.lisp and add a new list to the articles variable:
(list :title "How do I use cl-yag"
:id "2"
:date "29 April 2016"
:author "Solène"
:tiny "Read more about how I use cl-yag."
:tag "example help code")
Then write a corresponding data/2.md file, using markdown.
I prepared a Makefile to facilitate the process of generating and
publishing your static sites.
All you need to do in order to publish is to go into your cl-yag
directory and type make
.
The make command creates html and gopher files in the defined location. The default is the output/ directory, but you can use a symbolic link pointing to some other directory as well.
You may want to have some dedicated pages besides the index or a post. To create one, edit the generate-site function in cl-yag's generator.lisp and add a function call, like this:
(generate "somepage.html" (load-file "data/mypage.html"))
This will produce output/html/somepage.html.
cl-yags default Lisp interpreter is sbcl. If you want to use a
different interpreter you need to set the variable LISP to the name
of your binary, when calling make
:
make LISP=ecl
You may customize your publishing-process further, e.g. by using a git hook to call the make program after each change in the repo so your website gets updated automatically.
Here is an example code, if you want to include another page in the template:
Create templates/panel.tpl containing the html you want to include.
Add a replacement-string in the target file, where the replacement should occur.
In this case, we choose %%Panel%% for a string, and, because we want the panel to be displayed on each page, we add this string to templates/layout.tpl.
Modify the function generate-layout in cl-yag's generator.lisp accordingly.
This is done by adding the following template function call:
(template "%%Panel%%" (load-file "templates/panel.tpl"))
Another valid approach is to writer your html directly into templates/layout.tpl.
cl-yag crashes if you use a single "~" character inside templates/articles.lisp, because Common Lisp employs the tilde as a prefix to indicate format specifiers in format strings.
In order to use a literal ~
-- e.g. for creating a :title
or
:url
reference -- you have to escape the tilde by
duplicating it: ~~
. (See :url
in section 'Configuration').
cl-yag allows posts without tags, but, using the default templates/layout.tpl, you'll get a line below your title that displays: "Tags: ".
(Note: If you are looking for a way to contribute this may be a task for you.)
Although cl-yag may ship with a minimalist template, cl-yag focuses on generating html- and gopher-compliant structural markup - not themed layouts.
If you want some deeply refined, cross-browser compatible, responsive, webscale style sheets, you need to create them yourself. However, cl-yag will work nicely with them and if you want to make your style sheets a part of cl-yag you're very welcome to contact me.
I tried to make cl-yag easy to extend.
If you want to contribute, feel free to contact me and/or to send in a patch.