tags:

views:

138

answers:

5

I'm constructing a site with tutorials and other things. I'm trying to find a good URL structure. However, I have a conflict:

tutorials/ <-- list of all tutorials
tutorials/a-very-cool-tutorial <-- points to the very cool tutorial
tutorials/java <-- a list of tutorials tagged java
tutorials/java+soap <-- a list of tutorials tagged java and soap
tools/soap <-- soap tools
tools/wsdl-generator <-- points to the tool
resources/foo <-- resources for a foo
resources/foo+bar <!-- resource for a foo and a bar
tutorials/java?sort=newest
tutorials/php?showhidden=yes&count=30

It's impossible to resolve the difference automatically, so one of them has to be changed. Which one should I do

tutorials/show/a-very-cool-tutorial
   VS
tutorials/list/java
or list-of-tutorials or something like that?

I'm inclined to go with tutorials/list/ (and redirecting tutorials/ to that too)

+1  A: 

Why not

tutorials/ <-- all tutorials

tutorials/java <-- all Java tutorials

tutorial/a-very-cool-tutorial <-- the very cool tutorial

thus distinguishing between individual tutorials and lists of tutorials by using singular/plural. This removes any possibility of ambiguity, which may give you some sense of security :-)

Brian Agnew
That does not make sense to me. There could be more than one "very cool tutorial" over time. What then?
Cerebrus
The above assumes (not unreasonably in my opinion) that each tutorial will have a unique name. The tutorials/java is based upon Java tutorials being tagged appropriately (similar to how SO works with tags and questions)
Brian Agnew
+1  A: 

It's not 'impossible'. You can always have a method of checking if the last item in the path is a group or an item and act accordingly - passing control to the relevant code. I have used this technique before on a shopping site.

As the number of items is generally larger than the number of groups, I'd suggest checking if you are dealing with a group as a special case and fall back on item by default.

That's not to say that having an extra parameter in the URL is wrong, better or worse. But you can do it the way you originally stated.

Adam Pope
+1: There's no "conflict"
S.Lott
I didn't really give a lot of information, sorry. I've added some more examples to the question so you can see that it's quite hard (though maybe indeed not impossible) to do.
Bart van Heukelom
Ok, I think I can let the code distinguish. I'll just have to cut some possible URL forms.
Bart van Heukelom
There's still nothing like a conflict, even in the extended example. It's quite elegant and easy to do.
S.Lott
+5  A: 

Why don't you express the article hierarchy in the URL structure? You can write:

tutorials/ ← list of all tutorials
tutorials/java ← a list of java tutorials
tutorials/java/a-very-cool-tutorial ← points to the very cool tutorial

This way the visitor can tell that A very cool tutorial is a Java tutorial, and if you mind SEO, this version is good for that, too.

Edit

According to your comment, an article may have several tags, and your site has listings of articles that belongs to a tag set. In this case, you can choose this concept:

tutorials/
tutorials/a-very-cool-tutorial
tags/java ← tags have a separate prefix
tags/java+soap

Or another:

tutorials/
tutorials/a-very-cool-tutorial.html
tutorials/java/
tutorials/java+soap/ ← the trailing slash indicates that it's a listing

(And you can write a third one which may better or not.) It's the matter of your taste.

In addition to the scheme you choose, I suggest you to put the article ID or the publication date in the URL to avoid URL collision.

tutorials/20090509/a-very-cool-tutorial ← a visitor friendly way
tutorials/928/a-very-cool-tutorial ← ID in URL like how Stack Overflow does

Edit 2

Your latest update on the question clarified that aside from the tags, you both have something like categories—I mean tutorials, tools, resources. It gives an unnecessary complexity to the problem. I think it'd be better to handle these extra aspects as tags, too. So tutorial is just another tag like java, and this works with all of the ideas described above.

/a-very-cool-tutorial ← article (beware of URL collision)
/java/ ← all Java posts
/tutorials+java+soap/ ← all Java related SOAP tutorials
/tags/tutorials+soap/ ← you can use an extra prefix
Török Gábor
Yeah, that would be how I would do it, too !
Cerebrus
In this case it would work, but what about"tutorials/java+soap" or "tutorials/java/beginner" or "tutorials/java/hidden"
Bart van Heukelom
Well the first wouldn't work like that literally, because I have more than tutorials (edited the question again).The second would be easiest, but I somehow don't like the html appendix.
Bart van Heukelom
Oh, and I had the third one, but am now moving away from it :p
Bart van Heukelom
You needn't to have the HTML suffix, you can simply use the trailing slashes to indicate the listings, or any other method that is trivial for you to parse.
Török Gábor
I can't really merge categories and tags, because they behave quite differently. Each item has exactly one category, but 0..* tags. Tags are also just tags, but items in different categories are different. E.g., a tutorial may require more database fields, or the permissions for editing a tool are stricter. Also, users aren't supposed to notice that tutorials and tools are in fact using the same database, etc.
Bart van Heukelom
How you treat the categories or tags is really something that a user don't care about :) If you manage categories as tags, it does tell exactly nothing about the internal implementations. But of course, choose the solution that best fits your needs.
Török Gábor
A: 
tutorials/by-tag/java
tutorials/search/user-search-string
tutorials/   <-- all
tutorials/a-nice-tutorial

When parsing the url, you can look for these keywords. If it's unknown, it's a variable index passes to the parent 'resource' to resolve (The tutorials collection gets "/a-nice-tut", a search object is passed the searchstring, etc).

A: 

What's wrong with this?

tutorials/ <-- list of all tutorials
tutorials/a-very-cool-tutorial <-- points to the very cool tutorial
tutorials/tags/java <-- a list of tutorials tagged java
tutorials/tags/java+soap <-- a list of tutorials tagged java and soap

Seems much more intuitive to me, and avoids any ambiguity.

jalf