Spica Jekyll documentation
Pictures
How to add pictures to Spica: plain files, optional smaller WebP copies, cropping and focus, the sharing image, your avatar and the favicon.
Pictures live in assets/img/. A picture is a plain file, and you point to it with its path, such as /assets/img/posts/golden-hour.webp. That’s all you need. JPG, PNG and WebP all work. The sample posts keep their pictures in assets/img/posts/ and the sample projects in assets/img/projects/, but any folder works as long as the path is right.
The demo’s pictures
The pictures in your download are original artwork made for Spica, the same ones as on the live demo. Keep them or replace them. To replace one, save your own over the file with the same name, or add your own file and change the path in your page or post. When you’ve replaced everything you use, delete the rest of assets/img/posts/ and assets/img/projects/. Keep avatar.webp and og.png until you’ve made your own.
| Files | Used for |
|---|---|
avatar.webp |
Your picture, in the sidebar, the author box and the About page |
og.png |
The picture shown when a page is shared (1200 × 630) |
posts/ |
The sample posts’ cover pictures, and the gallery on the Elements page |
projects/ |
The sample projects’ covers and galleries |
Cropping
Every picture sits in a frame with a fixed shape, and the picture is cropped to fill it. A tall or wide picture never stretches, and its own size never changes the layout. The shapes are:
| Where | Shape |
|---|---|
| Cards on the home page, categories and projects | Standard (3 to 2) |
| The large featured card | Standard (3 to 2) |
Small picture in the list style |
A little squarer (4 to 3) on phones, then 3 to 2 |
| The cover on top of a post or project | Wide (16 to 9) |
| A figure | Standard (3 to 2) unless you choose another ratio |
| A gallery | Square, or its natural shape in the viewer |
Because a picture is cropped, choose which part stays in view with image_position:
image: /assets/img/posts/golden-hour.webp
image_position: "50% 20%"
The two numbers are how far across and how far down the focus point is. "50% 20%" keeps the upper part of the picture. A word such as top works too. A post’s image_position applies to its cover and its cards. For a figure, use position.
Faster on phones: smaller copies
For a sharp picture on every screen without sending a big file to a phone, add smaller WebP copies next to the main file, with the width at the end of the name:
assets/img/posts/golden-hour.webp the main picture, about 1600 pixels wide
assets/img/posts/golden-hour-960.webp a copy about 960 pixels wide
assets/img/posts/golden-hour-480.webp a copy about 480 pixels wide
Then write the path of the main file, as always. Spica finds the copies by itself and lets each browser download the smallest one that’s sharp enough. The main file counts as the largest size, so make it about 1600 pixels wide.
- The widths Spica looks for are
spica.image_widthsin_config.yml, which is[480, 960, 1600]. The last number is the main file. You don’t have to make every copy: any that are missing are skipped. - The copies must be WebP and named exactly
<name>-<width>.webp, in the same folder as the main file. This holds even when the main file is a JPG or PNG. - Without copies, the one file is used at every size. The site still works.
- If you change the list in
image_widths, rename the copies to match.
Spica doesn’t include an image tool, so export the sizes with any editor. Squoosh is free and runs in your browser. Save as WebP at around quality 80.
Pictures load lazily, except the big one at the top of the page, which loads first. The cover on a post, the featured card and the first picture in a list do this by themselves.
Your picture and the author box
Your picture is author.avatar in _config.yml. It’s a small round picture, so a square file about 200 pixels wide is enough. It uses the one file you give, with no smaller copies. Set it to your own file. If you leave the line out, the sidebar and the author box show no picture. The About page has its own <img> line at the top of about.md, so delete that line there too.
The sharing image
Set the picture shown when a page is shared with spica.share_image in _config.yml, and make it 1200 × 630 pixels. A post or project with its own image shares that picture instead. See SEO.
The favicon
Replace assets/favicon.svg with your own, or add favicon: /assets/your-file.svg at the top level of _config.yml. The theme serves it as an SVG, so make it an SVG file.
Pictures in a post
The post’s cover picture is image in its front matter. Inside the text, use a Markdown picture, or figure.html for a caption or a fixed shape, or a gallery. See Writing posts and Things you can put in a post. Always write an image_alt or alt that says what’s in the picture.