ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

HTML Sitemap Creation

July 09, 2012 6:15am

Subscribe [2]
  • #1 / Jul 09, 2012 6:15am

    Vivify

    10 posts

    Hi,

    I’m trying to create an HTML sitemap. I can generate a basic sitemap using the following code:

    <ul>
    {exp:channel:entries channel="pages" limit="50" dynamic="off"}
    <li><a href="http://{homepage}{url_title}">{title}</a></li>
    {/exp:channel:entries}
    </ul>

    The problem is that the links generated are not correct. They only add the last segment, missing out parts of the full path.

    Is there a tag I should be using that will do this?

    Alternatively, is there an add-on that would perform this task?

    I have NSM Better Meta, NavEE & Taxonomy, but I can’t see a way to get any of these to do the job. (No problems with an XML sitemap, but that’s not what I’m after).

    Thanks,

    Nick.

     

  • #2 / Jul 09, 2012 9:32am

    dirojas

    25 posts

    What about?

    {title_permalink="template_group_name/template"}

    So it would be something like:

    <a href="http://{title_permalink=%27sitemaps/index" title='{title}'>{title}</a>
  • #3 / Jul 09, 2012 10:05am

    Vivify

    10 posts

    Hi dirojas,

    Thanks for your quick response, much appreciated.

    What I am trying to get EE to do is spit out the actual page link (rather than the template path). For example: /about/facilities/library. As far as I can see using

    {title_permalink='pages/index'}

    just throws out /pages/library (unless I’ve missed something - which is quite possible).

    Do you know of a tag that will grab the same string that the pages module produces?

    Thanks,

    Nick.

  • #4 / Jul 09, 2012 12:13pm

    dirojas

    25 posts

  • #5 / Jul 10, 2012 4:41pm

    Kevin Smith

    4784 posts

    Hi Nick,

    Because of EE’s flexibility, channels and their entries don’t always map to a particular URL structure. So to make this happen, you’ll need to walk through a few steps. Even though you’re only making use of one channel, I’m going to give you steps that would work with a channel entries tag that’s outputting multiple channels’ entries so that your template will scale well in the future.

    1. Go to Admin > Channel Administration > Channels in your CP. Then edit every channel’s preferences and make sure Channel URL is filled out under the Path Settings section. This let’s EE know the URL structure to use for each channel.

    2. In your site map template, use {relative_url} in the places where you were using {homepage} in your first code example.

    When that template renders, you should now see all the proper links. Does that clear it up?

  • #6 / Jul 10, 2012 5:49pm

    Vivify

    10 posts

    Thanks Kevin,

    Appreciate your response.

    I just want to make sure I have interpreted your advice correctly.

    I have a channel called ‘Pages’. The URL for that channel (in the channel URL field) is dev.ccps.qld.edu.au/.

    My sitemap code looks like this:

    {exp:channel:entries channel="pages" limit="50" dynamic="off"}
    <li><a href="http://{relative_url}{url_title}">{title}</a></li>
    {/exp:channel:entries}

    The output gives me dev.ccps.qld.edu.au/about/library, but I need dev.ccps.qld.edu.au/about/facilities/library.

    Have I got the URL wrong?

    Thanks again.

    Nick.

  • #7 / Jul 12, 2012 5:38pm

    Dan Decker

    7338 posts

    Hi 8bits,

    Almost there! There are 2 approaches you can take here:

    {exp:channel:entries channel="pages" limit="50" dynamic="off"}
    <li><a href="http://{relative_url}facilities/{url_title}">{title}</a></li>
    {/exp:channel:entries}

    You can use that to add it in.

    If you want to use the full URL, you can use the path variable to build your links:

    <li><a href="http://{url_title_path=about/facilities}">{title}</a></li>

    Cheers,

  • #8 / Jul 15, 2012 8:03am

    Vivify

    10 posts

    Thanks Dan,

    It turns out all I needed was the {page_url} tag, as this provides the full URL to static pages.

    So, using

    <ul>
                        <li><a href="http://{homepage}">Home</a>
                            <ul>
                                {exp:channel:entries channel="pages" limit="50" dynamic="off"}                           
                                    <li><a href="http://{page_url}">{title}</a></li> 
                                {/exp:channel:entries}
                            </ul>
                        </li> 
        </ul>

    provided me with the basic structure I need to create an HTML sitemap. I can now make it more useable from here.

    Thanks to those that replied for your help.

    Regards,

    Nick.

  • #9 / Jul 17, 2012 12:49pm

    Kevin Smith

    4784 posts

    Awesome, glad to see you’ve found a solution that works for you. Is there anything else we can help with?

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases