Auto <p>, is this a bug?

I’m banging my head trying to understand if this is a bug or the intended behavior.
I have a simple controller that is passing the content ff a blog post to the template


return function($site, $pages, $page) {

    # Fetch Page Content
    $posts = $page->children()->visible()->sortBy('published' , 'desc');
    $post  = $posts->first();
    $title = $post->title();
    $text  = $post->text()->kt();

    # Return the content
    return compact('posts' , 'post' , 'title' , 'text');


In the template I then use a snippet to generate the post content

<?php snippet('post'); ?>

I tried both with and without variables passed as a second argument

In my snippet I then print the title as following

<h1 class="post-title"><?php e($page->isHomePage() , $title , "<a href='{$site->url()}'>{$title}</a>") ?></h1>

As a result I get this

<h1 class="post-title">
    <a href="/">
        <p>The Title</p>

Where does that extra <p> inside the link comes from?
I tried to get rid of it in every way possible. If I dump the value of the $title variable, the content clearly doesn’t have the extra p attached. If I echo $title (or $title->html()or $title->value) I still get the extra <p>

But, if inside my snippet I echo $page->title() then the p is gone.

Am I missing something here?

What version of Kirby are you using? If it’s 2.5.10, make sure its the version currently available for download. There was an issue to do with sorting at the point of release that was fixed and the download updated later on the day of release.

I don’t think thats causing your errant P tag though.

I can’t reproduce this, at least not in the current Kirby version. Have you tested this in a fresh Starterkit?

What plugin are you using?

I am running the 2.5.10 but I didn’t try it on a fresh installation of the starterkit.
I’ll do it now. As for plugins, I have one for the rss feed and one for the sitemap so I don’t think that’s the cause.

Ok this is quite strange. I tried on the Starterkit and the bug is indeed not there.
I removed the plugins and the bug is now gone. I added back the plugins and the bug is still gone.

So I have no clue what could have caused it in the first place.

O well, guess is time to eat something for lunch.
Thanks for the help @texnixe and @jimbobrjames

The problem wasn’t with the $text but with the $title :wink:
And as I wrote in my latest post the problem has gone away by itself.

I still have no idea what was happening though.