How to Create a Custom Post Template With "Snippets" Embedded Within {{content}}

Any selection can be a snippet, not just individual cards.

  1. Create a page with your html blocks and empty writing spaces
  2. Select all of the contents (Ctrl/Cmd+A can be easier than click+drag for long posts)
  3. Click the “Create snippet” toolbar button
  4. Use that snippet when creating a new post

7 Likes

Hey @Kevin,

Wow! I didn’t know you can do that! Yeah! Now that is something that will work for my current use-case!

Just perfect! Thank you so much! Plugs my current problem perfectly! Thank you!

@Kevin ,

do you think this feature has been documented somewhere ? i have a hard time searching for this in the official Ghost resources.

Snippets are covered in the editor help documentation Using the Editor in Ghost - FAQ

1 Like

@Kevin ,

thanks for your prompt reply.
and if i used the same snippet in more than 1 posts, then in a certain post i update that inserted snippet, will that change be reflected in all instances which exist in other published posts ?

No. Snippets are just like copy/paste but you have a stored list of things to “copy”. Once they’ve been inserted into a post they are indistinguishable from any other content in that post exactly as if you copy/pasted it from elsewhere.

@Kevin ,

Snippets are just like copy/paste but you have a stored list of things to “copy”

got it.

so if i have a particular custom feature to be added in some of my posts, with future updates expected, what do you recommend as the best approach, so that for all future updates, a single modification can have all instances updated as well ( i.e. without having to adjust each posts manually ) ?

See this thread, to the end.

1 Like

@Kevin - thanks for helping out so far. Question: I have seen the video created by you and of course we can create dyanmic HTML snippet right inside the editor and re-use them.

But I want to version them in the code. So I want to create my custom template, render the snippet code inside my .hbs file and as soon as I attach the template inside the ghost CMS editor, I want to immediately load the HTML snippets. Then of course I can edit them and add text etc and publish the page.

Do you think its possible? If you can show a way to do that.

Hi @Kevin,
Sorry for digging an old subject but I just tried your method to create a multiple node snippet and when I select all the content using CTRL+A, either I am on a text node and it triggers the blockquote feature or I am on a HTML node and it does nothing…
I also tried to select all content manually with the mouse but cannot select both text & html node.

I succeded in a previous version of Ghost but now it does not work anymore

Ghost version : 5.59.2 with Beta Editor (tried without, not working neither)

Hey there!

I was trying to duplicate the bug you were having but I couldn’t.

Here’s a video of what it looks like for me:

Can you share more about what’s happening for you?

Hi @RyanF
Thanks for your quick answer!

While doing the screencast I might have igured out a workaround but it is still not working as expected.
It is strange: the toggle blockquote key shortcut CTRL+Q is only working with CTRL+A on my computers (tested on 2, both using AZERTY as keyboard layout).

That’s why I cannot use CTRL+A to select everything on my page while being on a text node.

However, when I am on a HTML node, doing CTRL+A toggles all text blocks to blockquote BUT also select everything and allow to create a snippet.

Here is the video below
https://imgur.com/a/5y4qc35

Thanks for following up. Is this on Windows?

I tried both on Windows and Ubuntu.

Both using last version of Firefox

Do you have a Chromium browser that you can test?

I just tried with Chromium and it is not working :/

However the behavor is different: when I hit CTRL+A, it selects everything (at least I think, the HTML nodes are not in a “selected” style = highlited border) even if I am in a text node (it does not trigger blockquote).

But in all cases, usnig CTRL+1 or drag to select, the toolbar does not appear…

Do you need another screencast?

A recording would be great :pray:
I’m going to take a look on Windows to see if I can replicate it because I haven’t been able to on MacOS.

I just saw a commit potentially related to this issue: 🐛 Fixed code/html/markdown cards being removed when cutting content i… · TryGhost/Koenig@c84218e · GitHub

It took me some time but here it is!

Vidéo

Hi @RyanF
Did you have time to have a look?
I just saw new versions of Ghost 5.62.0 has been released (mine is 5.59.2), is there any chance a fix is in it?
Thanks !

Hey! Thank you for the recording, but I wasn’t able to replicate the issue :pensive:

I would try updating and see if the issue persists.

If possible, see if you can replicate on another device.

If you’re still having issues, please make a new post on the Forum, explaning the issue.