Is there a way to add a html tags like <a href""> as part of the Excerpt content?
Thanks.
Is there a way to add a html tags like <a href""> as part of the Excerpt content?
Thanks.
You might be able to use
{{content words="100"}}
Which should get you the first bit of your content with html.
and where should this be added?
Thanks!
Ah to be fair I was assuming you were editing your handlebars theme. If youâre not then Im not certain itâs possible to add html to the current custom excerpt field.
If you are youâd just swap out where you have {{excerpt}}
for {{content words=â100â}}
in the template file that you want to show it in.
Ok I just tried swapping
{{excerpt words=â100â}}
{{content words=â100â}}
in partials/post-card.hbs file. It seems to completely remove the content and just show the titleâŚ
This is the section:
{{#if feature_image}}
{{excerpt words=â30â}}
{{excerpt words=â100â}}
So to be super clear to make sure weâre on the same page, when you use the content helper itâs going to be showing the first 100 words of the main content of your post and not whatever you may have typed up into the box labeled excerpt
for the post.
That said you may want to backspace and handtype {{content words="100"}}
into your editor, because when I tried copying it just now it didnât work right either because some of the characters copied over in a way that didnât parse correctly even though it looked fine at a glance. (I got some different type of quotation mark that was curved rather than straight and that apparently was enough to throw it off).
Thanks for the detailed writeup.
You are right. {{content words=â100â}} seems to print just empty line even though I have hand typed content in the post body. I am still trying to figure out a workaround to handle html content especially a url with tag in excerpt section.
Instead of using the Excerpt field you might want to use one of the code injection areas, that way you can apply completely custom HTML for the excerpt. Note that you will need to customise your theme to repurpose the code injection field
@DavidDarnes is {{ghost_head}}
for a specific post accessible from its object when using something like {{get âpostsâ}}
?
Sorry Iâm not sure what youâre asking, could you rephrase the question?
@DavidDarnes
If I have code like this:
{{get âpostsâ}}
{{#foreach posts}}
< div>{{ghost_head}}<\div>
{{\foreach}}
{{\get}}
In home.hbs (whose context is a page Iâm replacing index with), should I be getting the code injection block for each post output in a div or will I just get the home pages code injection block instead?
Also a completely different question, the formatted for code segments in this part of the forum is terrible. Why is different from the other ones?
@Niion_Sports
So I was messing around in ghost trying to figure out various ways to access the different properties for a post and I found a way for you to put html in your excerpt and have it output the way you expect!
Wherever you want your excerpt with the html in it to show for the post youâll want to put this: {{{custom_excerpt}}}
âcustom_excerptâ is where the text you added as your excerpt, gets stored before Ghostâs builtin helpers do anything with it, and the triple brackets tells handlebars that you donât want it to sanitize the html tags present in the field.
Wow! thatâs a lot of messing around
Thanks for the tweak. I will give it a try.
@sunlanterns I hearted this for awesomeness, but I wanted to give this 10 hearts.
Since we are allowed only one heart per post, I am adding the additional 9 more here:
Amazing - this is exactly what I was looking for!
Hello,
Does the trick with the triple {} still working in the latest version of Ghost ? I have updated my Ghost server and it seems that the html code inside my custom excerpt is not any more showing the icon but only the text of the html code like " i class=âfa-solid fa-people-groupâ>]"