Nesta 0.14.0 is out (it's a big one)

Nesta 0.14.0 is out, and it brings the first significant new feature in almost a decade!

  • Nesta can now be used as a Static Site Generator.

    This means that you can now join the cool kids and deploy Nesta to a host of JAMstack-focused hosting services like Netlify, GitHub Pages, AWS Amplify, Cloudflare (and many more).

  • This release also includes a new library for converting Sass to CSS. This might require some minor code changes if you've got stylesheets written in Sass (see below for details).

  • Setting config via environment variables is no longer supported directly, but can be achieved by reading the environment within config.yml. See the CHANGES file for tips on how to do that.

  • Support for several (long since deprecated) features have been removed:

    • The local_stylesheet? helper method has been removed (deprecated in 0.9.1)
    • The breadcrumb_label helper method has been removed (deprecated in 0.9.3)
    • Plugins are no longer read from the ./plugins directory (deprecated in 0.9.10)
  • There have been a bunch of internal improvements to the code, which shouldn't affect you. See the CHANGES file for full details.

Upgrading

To install the new version edit your site's Gemfile and remove the version number (if it has one) from the end of the line, then run:

$ bundle update nesta

You should now be able to start up the site locally with mr-sparkle, and test it:

$ bundle exec mr-sparkle

If you have any weird errors when you start your server it could be a result of there being some fairly old gems installed. Update the entire bundle and try again:

$ bundle update
$ bundle exec mr-sparkle

Updating your code

Sass and SCSS files are now rendered with Dart Sass (the main implementation of Sass). We had been using the (now deprecated) libsass library.

Sass has changed a bit since libsass was current, so you may need to make some small changes to your stylesheets. See the Sass Breaking Changes docs for full details of what's changed.

If that seems like a lot to read, you can do what I did to see if you've got any work to do:

  • Fire up a local copy of your site (e.g. bundle exec mr-sparkle) and visit a few pages.
  • If Sass thinks you've got some work to do it'll print deprecation warnings in the server logs, including links to pages documenting any changes you need to make. Easy!

Building a static site

There's a new command to build your sites, and a couple of new settings in config.yml to help you configure your build.

I'll be writing more expansive docs on this, but if you'd like to try it, these tips should get you going:

$ cd mysite.com
$ bundle exec nesta build  # builds in ./dist by default

If you'd like to build the output in another directory, specify it on the command line:

$ bundle exec nesta build _site  # builds in ./_site

Checkout the bottom of the default config file for an example of how to use the new config settings.

I've not written docs on deploying to any static site hosting services yet, but if you fancy giving Netlify a shot (which is easy, and free) you can configure it by adding a netlify.toml file to your project. It should contain the following lines:

[build]
  command = "bundle exec nesta build"
  publish = "dist"

You'll also want a .ruby-version to tell Netlify what version of Ruby you'd like them to use. At the time of writing, Ruby 3.2.1 is the latest release.

$ cat .ruby-version
3.2.1

If you then give Netlify access to your Git repository, it should be able to build and deploy your site! Let me know how you get on...

Published on