Forum

Thread tagged as: Question, Blog

How do I make blog posts sit under their section url?

I have two blog sections, one lives under site.org/blog the second lives under site.org/page/blog. At the moment I have posts appearing in the correct place, however the blog posts under the second section have urls that live under the first section. I need those posts to have the url site.org/page/blog/title but I can't figure it out.

Anyone able to point me in the right direction?

Phil Bowell

Phil Bowell 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Have you included the {sectionSlug} in the post page URL in settings?

EDIT I realised my error and included a posts.php in the folder and it worked. Thanks Drew.


I hadn't. I added that in to Blog post page path so that it looks like /{sectionSlug}/post.php?s={postSlug} and the slug format is {postTitle}.

That of course breaks everything and every post url gives a 404 error which says

The requested URL /romans158/post.php was not found on this server.

romans158 is the section slug and also the name of the folder that the new blog page resides in.

The template I'm using to display the blog posts in a list is

<perch:before>
<ul class="hfeed listing"></perch:before>
    <li class="hentry">
        <h3><a href="<perch:blog id="postURL" />" rel="bookmark" class="entry-title"><perch:blog id="postTitle" /></a></h3>
        <perch:blog id="excerpt" type="textarea" markdown="true" />
        <p class="entry-published date">Published on <perch:blog id="postDateTime" format="%A, %e %B %Y" /></p>
    </li>
<perch:after>
    </ul>
    <perch:if exists="paging">
        <div class="paging">
            Page <perch:blog id="current_page" /> of <perch:blog id="number_of_pages" />
            <perch:blog id="page_links" encode="false" />
            <perch:if exists="not_first_page">
                <a href="<perch:blog id="prev_url" encode="false" />">Previous</a>
            </perch:if>
            <perch:if exists="not_last_page">
                <a href="<perch:blog id="next_url" encode="false" />">Next</a>
            </perch:if>
        </div>
    </perch:if>
</perch:after>