lanyon

lanyon

Lanyon serves your Jekyll site as a Rack application.

Lanyon

Lanyon serves your Jekyll site as a Rack application.

Lanyon is a good friend of Jekyll, the static site generator, and transforms your website into a Rack application.

Getting Started

Assuming you already have a Jekyll project that can be built and served using the jekyll command line tool, then converting it to a Rack application is very simple.

  1. Add the Lanyon gem and one of the web servers supported by Rack (e.g. Puma) to your project's Gemfile:

    gem "lanyon"
    gem "puma"
    

    Then install the gems by running the following in the terminal:

    bundle install
    

    For possible other choices for web servers see Rack's README.

  2. Add a config.ru file in your project's root directory, with the following content:

    require "lanyon"
    
    run Lanyon.application
    

    You can specify additional Rack middleware in this file.

  3. Build the site and start the web server with the following command:

    bundle exec rackup config.ru
    

You can find an example site in the demo directory.

Note that Lanyon does not watch for site changes. Auto-regeneration similar to Jekyll's serve command is not supported, and there are no plans to add this feature.

Lanyon applications can be served with WEBrick, Puma, Thin, and many other web servers, and they can be deployed to services like e.g. Heroku.

Configuration

Options

Jekyll configuration options can be specified in a _config.yml file or as Lanyon initialization options in config.ru.

Example:

run Lanyon.application(destination: "mysite")

This will set a custom destination path, overriding the default (_site) and settings from a config file. See Jekyll's documentation for more settings.

Additional Lanyon initialization options:

:config       - use given config file (default: "_config.yml")
:skip_build   - whether to skip site generation at startup
                (default: false)

Note that on read-only filesystems a site build will fail, so you must set skip_build: true in these cases.

Custum 404 Page

You can provide a custom 404.html file in your site's root directory. This can also be a file generated by Jekyll from e.g. Markdown sources.

Requirements

  • Ruby 3.1 or higher

  • Gem dependencies (runtime): jekyll, rack

How URLs are resolved

Lanyon maps URLs to corresponding files as follows:

  1. a path/ with a trailing slash is changed to path/index.html,
  2. then, Lanyon checks for an exactly corresponding file,
  3. when path does not exist but path/index.html does, the response will be a redirect to path/,
  4. when neither 2. nor 3. apply, +path.html+ is tried.

To avoid confusion, it's probably a good idea to have only one of resource, resource/index.html, and resource.html present as file in your site.

Reporting Bugs

Report bugs on the Lanyon home page: https://github.com/stomar/lanyon/

Credits

Lanyon was inspired by rack-jekyll and written as a replacement.

License

Copyright © 2015-2024 Marcus Stollsteimer

Lanyon is licensed under the MIT License. See also the included LICENSE file for more information.

jekyll logo

Want a Jekyll website built?

Hire a Jekyll developer