4

Just a quick question regarding the URL (template) structures in expression engine.

I have an established site that has been live for almost a year. I was brand new to EE when I set up and therefore I am finding better ways of building the site all the time.

I have a template group and set of templates like so

template_group/template/

walks/find/
walks/findwalk/
walks/view/
walks/search/

obviously walks/view/ is is my single entry template.

walks/find/ is my main listing template. This includes a list of all the latest entries, together with a search box.

walks/findwalk/ is exactly the same as the find template, but it displays results from categories, so the url ends up something like walks/findwalk/category/(catergoryname)

walks/search/ is the same again, except it contains my search results.

I know, not very DRY, but I was new.

So I am looking at simplifying it slightly and condensing the templates down. The way I see it, I would be quite happy to have single page view separate, and a single template for the listing page.

I have just started using Switchee, and I think this would be good here.

Ideally my listing template would be walks/find/ which, by using switchee, would check for {segment_3}

walks/find/search
walks/find/category
walks/find/

So that's fine. Nicer URL's, less templates. However, I am a bit unsure as to how this will effect my current search results in search engines.

By far, the url thats hit on most is walks/find/, so that will stay the same, but then nearly all the next most hit urls are: walks/findwalk/category/(category_name)

What will happen to these results in google? Is there a way to ensure the links stay active?

Sorry for the long post!

EDIT:

Just realised I'm not even using the index template within the template group, so i could clean these urls up a bit further but dropping the need for find altogether.

walks/search
walks/category
walks/
walks/(entry_title)

This would look a lot better. Just wondering if there is a way to drop the category at all? This would mean i could get walks/category_name/entry_title which would look better still!

5

You'll want to add 301 redirects to your .htaccess file, with the old URLs mapped to the new URLs.

You can parameterize those redirects, so you can match on /walks/findwalk/category/[value] and have it insert that value in your new URL structure.

You'll want to Google '301 redirects htaccess' for pointers. I've also found Perishable Press to be a good htaccess resource in the past.

Specifying 301 (permanent) redirects will instruct Google to update its index, with the new URL as the permanent, new location for that content.

Updated: If you want to omit the /category/ segment, you'll need conditionals to catch the other segments and handle those. If one of those cases is not met, you can assume a category ID or category url_title, and branch your logic to present results accordingly. At that point you're using your index template as a router, and routing the request to embed templates based on the values on the URL. You would need to do a lookup on segment_2 to see if there were any entry matches. If not, you'd need to bounce to an embedded template to look up category matches for segment_2.

Maybe just use a word other than 'category' for segment_2 rather than complicate your templates?

Updated: As suggested in the comments, Detour Pro looks like it will cover all of the 301 redirect goals, though I haven't personally used it.

  • That's great, I shall do some reading! – shorn Jan 30 '13 at 18:28
  • 1
    Knowing your way around .htaccess is, as Mark said, the best option. I just wanted to mention Detour-pro, which looks like a nice add-on that could help you manage a lot of redirects. devot-ee.com/add-ons/detour-pro – Jérôme Coupé Jan 30 '13 at 19:55
  • Thanks for the update. Yes I think trying to remove the category might be more effort than its worth at the moment. I'll keep considering it. Thats Detour Pro looks good. Can I ask do you know what the advantage/disadvantage is over using that add on as opposed to the .htaccess file? – shorn Jan 30 '13 at 20:09
  • 1
    I'm not personally familiar with Detour Pro, but looking at its Devot:ee page, it looks like it will cover your goals and save you some regex/htaccess pain. – Mark J. Reeves Jan 30 '13 at 20:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.