Positioning text inside of var output in a template

This might be a stupid question but I dont think I know if I can print information within a output. Right now I am modifing a list template to create a better looking list with more links at the end of the truntcated text. What is happening is the link with the variable is being put outside the the the p tags and I want it inside the output so the “…more” link sits right up against the output. Is there a way to do this?

Here is my code:

<div>
    <h2><a href="{{ .Permalink }}">{{ .Title }}</a></h2>
    <div class="article-style">
      {{ if .Params.summary }}
      {{ printf "%s" .Params.summary | markdownify }}
      {{ else if .Truncated }}
      {{ printf "%s" .Summary | markdownify }}
      {{ end }}
	  <a href="{{ .Permalink }}">...more</a>
    </div>
  </div>

Here is an image of my list template output:

I am sorry but I don’t get it, the code doesn’t work if you put it after the printf command ?

Can you share the html output please? I feel this may be easier to fix on the css side of things.

It puts it outside the p tags for some reason, below is the code:

<div class="article-style">
      <p>If you have a question or problem with your device, and your Internet connection is still working, I can service your device over the Internet. I can speak with you over the phone while I am looking at the problem and give you a cost analysis.</p>
     <p></p>
	  <a href="//localhost:1313/services/computer/assistance/online/">...more</a>
 </div>

Never mind, I am sorry I didn’t think it though. I had carriage returns at the end of each document that the list template was rendering.

1 Like

Is there a way to print a custom string inside of a template file?

I want to show a more link in a list template only if there is a summary.

  {{ if .Params.summary }}
  {{ printf "%s" .Params.summary | markdownify }}
  <a href="{{ .Permalink }}">...more</a>
  {{ else if .Truncated }}
  {{ printf "%s" .Summary | markdownify }}
  {{ end }}	

Right now the link does not print when its between the functions. I attempted to try and make a shortcode, but that does not seem to render, it looks like shortcodes are only usable in markdown files.