Publican v0.8.0 update

By Craig Buckler

925 words, 5-minute read

root
Image courtesy of Eilis Garvey

Publican v0.8.0 was released on .

There are no breaking changes, but the following features have been added.

Alternative index filenames #

By default, Publican uses content slugs ending in index.html to create friendlier directory-based URLs. Content at blog/index.md is rendered to the slug blog/index.html.

You can choose an alternative index filename if necessary:

publican.config.js excerpt

// index filename
publican.config.indexFilename = 'default.htm';

This changes how slugs are created: content at blog/index.md is now rendered to blog/index/default.htm. You would need to rename the content file to blog/default.md to render it to blog/default.htm.

New post content properties #

The following post content properties have been added:

Post data.menu property defaults #

The front matter menu value (and the data.menu content property) sets a page title used in menus that is usually shorter than the real title, e.g.

---
title: How to contact us
menu: Contact
---

Setting index: false allows you to omit a page from menus or breadcrumb trails by examining it’s value in tacs.nav global property.

From Publican v0.8.0, when menu is not set in front matter:

Post data.index property defaults #

The front matter index value (and the data.index content property) sets the search engine indexing frequency.

Setting index: false omits a page from the global tacs.dir property so it does not appear in directory indexes and sitemaps.

From Publican v0.8.0, rendered files that are not HTML or index pages are set false by default unless explicitly overridden. It’s no longer be necessary to set index: false in the front matter for files such as XML, SVG, CSS, JavaScript, etc.

Other post property changes #

The following properties have changed:

Improved CSS file processing #

Publican can process CSS files like any other text content. Files are copied as-is but you can insert jsTACS ${ expressions } if necessary.

Previous releases of Publican failed to process files containing CSS character entities in \XXXX format, but this has been fixed.

Improved JS file processing #

Publican can process client-side JavaScript files like any other text content. Files are copied as-is but you can insert jsTACS ${ expressions } if necessary. Note:

  1. You cannot use backtick (`) characters inside expressions.
  2. Template literals intended for runtime processing must use !{ expressions }

For more information, refer to template literals in JavaScript.

New processRenderEnd event hook #

A new function hook named processRenderEnd is called once after all rendering and file writes are complete. It’s passed an array of changed file objects ({ slug, content }) and the global tacs object.

The function cannot change how files are rendered, but it can log changes or run other processes.

New basic theme #

A new basic Publican theme is available at:

The theme is fast, standards based, and uses best practise techniques. It features pages, blog posts, tag indexes, a light/dark switcher, RSS feed, sitemaps, security, and a 100% Lighthouse score.

Please download and adapt the theme for your own purposes.

New LiveLocalhost server #

The basic theme uses Publican alone for rendering – there are no other dependencies. In development mode, it provides a livelocalhost server to automatically reload HTML and CSS when files change.