Spica Jekyll documentation
Comments and search
Turn on Giscus comments stored in your GitHub Discussions, and learn how Spica's search finds posts and projects without a search service.
Comments
Spica’s comments use Giscus. They live in your GitHub repository’s Discussions, so there’s no database, no ads and nothing for you to host. Readers sign in with GitHub to write a comment. Comments are off by default.
Turn them on
- Put the site in a public GitHub repository and turn on Discussions in its settings.
- Install the Giscus app on the repository.
- Go to giscus.app, enter your repository and pick a Discussions category. It gives you four values.
- Set them in
_config.yml:
spica:
comments:
provider: giscus
repo: your-name/your-repo
repo_id: "R_kgDO..."
category: Comments
category_id: "DIC_kwDO..."
mapping: pathname
Comments show on posts only, under the author box. Nothing shows until provider is giscus and both repo_id and category_id are filled in. Leave mapping as pathname.
How they behave
- They load on request. A post shows a “Show comments” button. Giscus and its scripts load only when a reader clicks it, so comments never slow the page down.
- They follow the color mode. Giscus opens in dark or light to match the page at the moment of the click.
- They use the site’s language (the first two letters of
langin_config.yml) where Giscus has it. - Each post has its own thread, matched by the post’s address.
To turn comments off on one post, set comments: false in its front matter. The wording around the button comes from _data/strings.yml (comments, comments_note and show_comments).
Search
The Search link in the sidebar goes to /search/. Search needs no service and no account. It works like this:
- When your site builds, Jekyll writes
search.json, a list with every post and every project: title, address, date, category, tags, a short excerpt and the full text. For a project, the category is the word “Project”, the excerpt is its subtitle, and the tags field holds its client and role. - The search page reads that file only when it’s needed: when someone clicks into the box, starts typing, or arrives with a search already in the address.
- It shows the posts and projects that contain every word the visitor typed, with the matches marked. A match in the title ranks highest, then tags and category, then the excerpt and text. Matches are found inside words too, so
typefinds “typeface”. - Because the index holds the full text, a site with very many long posts has a bigger file. It’s fetched once, and only by visitors who search.
Write a good excerpt and use tags, and the right posts rise to the top.
Without JavaScript, the page still loads and points visitors to the Tags page and the Archive.
Search link and box
The sidebar’s Search link is spica.search. Set it to false to hide it. The 404 page also has a search box (404.html). The search page is kept out of search engines and the sitemap.
To remove search altogether, set spica.search: false, delete search.html and search.json, and remove the search box from 404.html (the line with search-form.html).