Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

88 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tufte

Demo GitHub jsDelivr Lume Theme

General-purpose Lume theme based on Tufte CSS.

Screenshot of Tufte demo homepage

Features

  • Styling with Tufte CSS: Uses a modified version of Tufte CSS, a popular CSS micro-framework created in 2014 by David Liepmann based on the work of Edward Tufte. Its wide margins and beautiful serif typography create a clean, sophisticated aesthetic.
  • Expressive Syntax: Includes several plugins that extend standard Markdown syntax for things like sidenotes, complex math blocks, <figcaption> tags, and more, all without writing a single line of HTML. See the Syntax section for more information.
  • LumeCMS Integration: Features a comprehensive _cms.ts file that allows for no-code content management of the entire site using LumeCMS.
  • Perfect Lighthouse Scores: Earns perfect 100s in performance, accessibility, best practices, and SEO on Lighthouse.

Quickstart

Tip

This quickstart is for creating your own Lume site using the Tufte theme. If you just want to check out the theme, visit the live demo.

Prerequisite: make sure to install Deno if you haven't already. I'm using Deno 2.8.1, but it'll probably work on other versions.

deno run -A https://lume.land/init.ts --theme=tufte
deno task serve

How it Works

Under the hood, the Tufte theme is a Lume plugin that automatically loads a bunch of plugins, layouts, components, and stylesheets.

Remote Files

When you install the Tufte theme, you won't see any of its internal files in your site. This is because the theme internals are loaded as remote files via Lume's site.remote() API. This keeps your site's repo clean while still making the necessary theme files available to Lume.

Tip

Because local files take precedence over remote files, you can override the theme internal files by creating an identically-named file in the same location, if you were so inclined.

Plugins

Tufte uses 12 Lume plugins and 6 markdown-it plugins to add syntax, optimize performance, and handle internal theme logic.

Syntax plugins

These plugins add syntax that you can use when writing page content. See the Syntax section for a guide.

Optimization/SEO plugins

These plugins are used to make pages load faster, improve SEO, or other invisible-but-important things. 100s in every category on Lighthouse doesn't just happen, you know.

  • imageSize: adds width and height attributes to images to prevent layout shifts on page load.
  • sitemap: generates the sitemap.
  • feed: generates the RSS feed.
  • favicon: optimizes the favicon and converts it to different formats.
  • Though it's not a plugin, the fontPreloads.vto component definitely fits in this category. It selectively preloads only the font files that each page uses. This prevents FOUT without adding unused global preloads.

Internal plugins

These plugins are used to make other parts of the theme work.

  • sass: transpiles the SCSS stylesheets into browser-consumable CSS files.
  • basePath: prefixes relative URLs (e.g. /about) with a subpath, which allows the site to be deployed on services like GitHub Pages.
  • metas: adds <meta> tags to the <head> of each page for things like titles, descriptions, and the favicon.
  • readingInfo: counts the words of each page, which is used in the blogList component's post info.
  • search: allows layouts to query and filter pages, which is used in the blogList component to list the posts.

Syntax

A more in-depth guide to the Tufte theme's syntax is available here.

Sidenotes

Sidenotes are like GFM footnotes, but they're inline and the numbering is automatic. Just put the sidenote text inside a pair of square brackets with a caret immediately following the left bracket.

Example:

This is my[^"my", in this case, referring to me.] paragraph text.

Result:

Sidenote demo

Margin notes

Margin notes are like sidenotes but without numbers. The syntax is the same but with an asterisk after the caret.

Example:

I am the very model of a modern major general.[^*No idea why I picked this as the example.]

Result:

Margin note demo

Subtitles

Subtitles are text that is italic and has a large font size. You can turn any paragraph text into a subtitle by adding {.subtitle} to the end of the line.

Example:

Written by A Bunch of Bees {.subtitle}

Result:

Subtitle demo

Math

Math is rendered using KaTeX, which uses the same syntax as TeX. A list of KaTeX syntax is available here. You can start a math block by using the math language in a code block.

Example:

```math
x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}
```

Result:

Math demo

Figcaptions

<figcaption> tags are added using image title syntax. Just add quotes after the source URI.

Example:

![Alt text](/uploads/seattle.jpg "A photo I took of Seattle from the Space Needle")

Result:

Figcaption demo

Fullwidth

On wide screens, the main content only occupies 55% of the screen width. To make an element take up more space, add {.fullwidth} to the end of the line.

Example:

![A photo I took of the Rock of Ages quarry in Vermont](/uploads/quarry.jpg) {.fullwidth}

Result:

Fullwidth demo

Epigraphs

To use Tufte CSS epigraphs, add {.epigraph} to the end of a blockquote and add {.quotecite} to the next paragraph text.

Example:

> On two occasions I have been asked by members of Parliament, 'Pray, Mr.
> Babbage, if you put into the machine wrong figures, will the right answers
> come out?' I am not able rightly to apprehend the kind of confusion of ideas
> that could provoke such a question. {.epigraph}

— Charles Babbage (inventor of the automatic calculator), 1864 {.quotecite}

Result:

Epigraph demo

Code

You can use Nueglow's special syntax for highlighting specific sequences and lines.

To highlight a section, surround it with single bullet markers (e.g. •important•). To underline a section, surround it with double bullet markers (e.g. ••mistake••). To highlight an entire line, begin it with a greater than sign (>). To render a diff, use plus signs (+) and minus signs (-) to start inserted and deleted lines, respectively.

Example:

```ts
interface User {
  id: number;
  name: string;
}

function greet(•user: User•): string {
> return `Hello, ${user.name}!`;
}

-const me: User = { id: 1, name: "Not Ethan" };
+const me: User = { id: 1, name: "Ethan" };
console.log(••greet{me}••);
```

Result:

Nueglow demo

Collapsibles

To add <details> tags, use the markdown-it-collapsible syntax. It’s very similar to the code block syntax, except you use plus signs instead of backticks.

Example:

+++This is the summary

This is the collapsible content. You can put anything you want in here.

+++

Result (shown in collapsed form and in expanded form):

Collapsible demo

Table of Contents

To add a table of contents, use the syntax from markdown-it-toc-done-right: place any of ${toc}, [[toc]], [toc], or [[_toc_]] anywhere on a page and the plugin will automatically replace it with a table of contents based on your headings.

Example:

[toc]

Result:

Table of Contents demo

Showcase

Here are all the sites that I'm aware of that use the Tufte theme. If your site uses the Tufte theme and you'd like it to be featured here, feel absolutely free to open a PR!

Acknowledgements

Everything else, including two of the external plugins (lume_nueglow and markdown-it-smart-media) and both of the internal mdit plugins (tufte-notes and tufte-sections), was made by me.

License

This project is under an MIT License. See LICENSE for more information.

About

General-purpose Lume theme based on Tufte CSS

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages