Best practice for having partials in content

Hello there,

A lot of the time I want to have a signature (like at the bottom of an email) at the bottom of my page. It seems natural to me to have a content page that has the signature in it, then show that page sort of like a partial in a template.

What would be the best practice to get this sort of thing done?

Is it shortcodes?

Thank you

Do you mean signature on every single post?

shortcode can be a great solution,

the pros:

  • You can display the signature only if you want it

the cons

  • You have to add the shortcode manualy

I would prefer to create a partial HTML and put it on your blogpost layout or something else right after the content div

here’s the benefit

  • it’s automaticly added, You don’t have to add any shortcode anymore
  • You can still control the signatures via front matter (in case You only need to put the signature on certain content only)
2 Likes

Thank you Yudy_Ananda,

Ahh ic, I like the idea of being able to switch it on/off using front matter. (I’m new and I only just grasped what front matter was, had to read the jekyll website to understand that). Sorry for my ignorance, but how would one do that? or what can I search for on the website to find how to do that?

Thank you, really appreciate your help

In syndicated media the signature is commonly referred to as a “byline”. Check out the source for some of the available themes to get an idea for how to accomplish it.

Here is the Docs and Hugo also have a complete documentation about front matter

The idea is to create and put the key in front matter of your content, eg signature or something else, and for the value you can chose beween true of false

---
signature: "true"
---

the next thing to do is to create some conditional logic code inside the partial, with the function more or less like “hey Hugo show the signature if the signature value is true and dont display if the value is false”

and then put the code right after the element or div of your content

for the refference eq or if

English isn’t my first language, so please excuse any mistakes

Brilliant, thanks Yudy you are very helpful. I understand now and I see how this will work. I am giving it a try now…

I had found the front matter documentation. It just doesn’t make it clear what exactly front matter is. (At least it wasnt to me). Perhaps I am daft though :slight_smile: I am a dotnet developer by trade :slight_smile:

Thank you kindly for your help, I shall endevour to pay it forward
John