Hosting with 20% off when you buy through the link
v3.9New in this version

Blocks in the text

Since v3.9.0 the text editor takes blocks the theme designs — big numbers, a testimonial, a call to action — inserted between two paragraphs and filled in a short form.

A blog post is mostly paragraphs, but now and then it needs something with a shape of its own: three big numbers from a case study, a client's testimonial with a photo, a box inviting the reader to book a call. Since v3.9.0 the text editor (the richtext field) takes blocks for that. You decide which blocks exist, the AI declares them in the theme, and the author inserts them between paragraphs with the Block button.

The author fills in data, not layout: how a block looks comes from the theme, so this year's testimonial looks like last year's. A page assembled from blocks (the flexible field) is something else: there the whole page is a stack of sections; here the blocks sit inside one flowing text.

Ask the AI

In the blog posts' text, I want three blocks the author can insert between paragraphs: - Big numbers: up to four, each with the number and a short label - Testimonial: the quote, the person's name, their company and a photo - Call to action: a title, the button text and the button link Only the post body accepts them; the texts of the pages stay as they are. Style the blocks like the rest of the site and run schema:validate at the end.

Naming each block's fields designs the form the author will fill in. Saying which texts accept blocks leaves the other editors as they are.

Another example

On the clinic's treatment pages, let the description accept two blocks: “Before and after” (two photos and a caption) and “Questions” (a list of questions, each with its answer). Nothing else changes.

A block takes any kind of field: images, a list of rows, a link.

What the AI does

  • Declares each block once in site.json, under richtext_blocks: its name in the admin, its fields and the file that draws it.
  • Lists the blocks on each text field that accepts them. A field accepts no block until it lists one.
  • Writes one small template per block in theme/partials/richtext/, with its CSS. On the site a block inherits the styles of the text around it.
  • Makes the theme print the text through richtext(), a function that swaps each block for its template. Without it the blocks don't show, and nothing breaks.
  • Runs schema:validate, the structure check, which confirms the declaration, that each block's file exists and that the theme calls richtext().
What the AI runs
$ ./bin/velk schema:validate ✓ site.json is valid. # checks the blocks, their files and the richtext() call $ ./bin/velk serve ✓ Velk serving on http://localhost:8080
Then open a post in the admin, insert each block and look at the post on the site.

In the admin

  1. Press Block

    Texts that accept blocks have a Block button in the toolbar. It opens a window that starts with the choice of block — since v3.9.1, even when the field accepts only one.

  2. Fill in the form

    The window shows the block's fields: a number, a photo from the media library, a list of rows. Save block puts a card in the text where the cursor was.

  3. Move or change it

    The card shows the block's name and a one-line summary, not the site's look. Drag it to another spot, press Edit (or double-click it) to change it, or select it and delete it.

  4. Check the site

    Open the post on the site: each card becomes the block drawn by the theme.

Where a block can go

A block lives between paragraphs, never inside a list, a quote or a table: inserted in a list, it splits the list in two; in a table or an image caption, the card goes right after it.

If a field stops accepting a block, or the block leaves site.json, the cards already in the texts stay, marked Unavailable block, and can be moved or deleted; the editor never drops them on its own. On the site, a block still declared in richtext_blocks keeps showing; one removed from it shows nothing.

The quote button

Since v3.9.0 the toolbar also has a Quote button. It turns the current paragraph into a quote and, pressed again, back into a paragraph; typing > at the start of a line, or Ctrl/Cmd+Shift+B, does the same. The editor saves a plain quote. How it looks on the site — a line on the side, larger letters — is the theme's job, so ask the AI to style it once, for every text.

Questions

Can the AI write a post with blocks for me?

Yes. On a live site it uses the content commands, which refuse a badly formed block, naming the field and the block, instead of saving it broken.

What about a site in several languages?

Each language's text has its own blocks: insert them in every language tab where you want them.

Can a block show a video?

Yes. If the site's security policy limits which other sites can appear inside its pages, the video site has to be on that list.