I DO want to use the category URL titles in my links, but I want the URL to have to look like this (for SEO purposes):
mysite.com/really-neat-blog-name/my-awesome-category-name
Any way around this?
This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
October 28, 2011 3:46pm
Subscribe [9]#1 / Oct 28, 2011 3:46pm
I DO want to use the category URL titles in my links, but I want the URL to have to look like this (for SEO purposes):
mysite.com/really-neat-blog-name/my-awesome-category-name
Any way around this?
#2 / Oct 28, 2011 5:05pm
This addon may help - http://gotolow.com/addons/low-seg2cat 😊
#3 / Oct 28, 2011 6:25pm
Thanks! I’ll check it out… I see the magic phrase “no more awkward category keyword identifier in your URIs” in the addon’s description!
#4 / Oct 29, 2011 9:50pm
Good luck understanding how that add-on works. I’ve stared at it for hours but have no idea what it’s supposed to do or how it works. The description of what it’s for to me is, well, Dutch ...
#5 / Mar 07, 2012 5:03am
Seg2Cat is definitely a lifesaver when you want to build custom URLs. Its many tags are well documented (in English).
Another great add-on for making non-standard URLs is Freebie: https://github.com/averyvery/Freebie
#6 / Mar 07, 2012 5:12am
I’m going to jump in here and try to take it back to the basics of what that add-on does.
It’s not too hard but sometimes you need to try something to fully “get it”.
On each page load it:
looks at each URL Segment (each bit of text in-between the forward slash character ‘/’ )
Then it does a sql query to see if any of those bits of text are category names
If one or any of those bits of text actually are category names, it extracts all the information that is entered about that / those categories
Then it registers that info as variables you can access in your templates at any given time in a easy to understand format which is like “{segment_n_category_id}”
The ‘n’ bit in that bit of code refers to which url segment the word was found in. If your address was http://www.example.com/john/bob/ and you had a category with the name “bob” then you could find the id number of that category here {segment_2_category_id} because “bob” is the second part of that url after the domain name.
See?
#7 / Mar 07, 2012 7:17am
Thanks johndhq. What you say makes some sense, but I still don’t have much idea of what I might do with this add-on or why I might need it. For example, I don’t see how it answers the initial question. I’m no EE ninja, so I lack a wide view of what things it makes possible, even without additions like this.
#8 / Mar 07, 2012 7:23am
Well, lets break down his url and see how it will work.
He has mysite.com/really-neat-blog-name/my-awesome-category-name which means that “really-neat-blog-name” is the name of his template group.
So in that template group, he can have the index template have some code like this in it:
{exp:channel:entries category="{segment_2_category_id}"}
{my-content-tags}
{/exp:channel:entries}And that will show content from the category that is in his url because we are using the mighty low seg2cat. You have to use a category id in that channel tag and the only way to get to that is with seg2cat. As seg2cat is early parsed it’s available to be used in a channel tag.
Ok?
#9 / Mar 07, 2012 7:30am
I think I seriously lack a developer mind set. It seems this means the URL is determined by the page content, but the page content is determined by the URL ... which is kind of a circular argument, isn’t it?
#10 / Mar 07, 2012 7:35am
EE URLs are only partially based on content. Portions also come from template group and template names.
I’d suggest a review of:
http://ellislab.com/expressionengine/user-guide/general/urls.html
I’d also suggest a solid understanding of how EE works with categories natively:
http://www.train-ee.com/courseware/free-tutorials/comments/working-with-categories/
The value of an add-on like Seg2Cat is much easier to grok when you understand what it was created to circumvent.
#11 / Mar 07, 2012 7:37am
No, you make the URL’s yourself. I might in a page choose the link to be John Which you need to remember relates to at a minimum the template group “blog” then possibly the template “index” or you may have the template “cat_name”.
Then in that template, you choose what content goes in there. It could be anything. The page content is not necessarily defined by the URL.
I agree, conceptionally it can be confusing at first. The only way to learn is to build something. It’ll make sense as you overcome theoretical problems as you’ll search with the same questions as your predecessors and see the answers given which they’ve learned by.
#12 / Mar 07, 2012 7:53am
Thanks guys. I’ve built about 6 EE sites that use categories in various ways, so I’m used to the basics of URLs (at least at a basic level). Normally, if I were searching entries in a category, I’d end up with something like
mysite.com/group/template/category/category-name
and posts assigned to category-name would be listed on the page. How any of that relates to seg2cat I truly have no idea, though.
Anyhow, don’t try too hard to explain it to me, unless you are into flogging dead horses. 😊
#13 / Mar 07, 2012 7:56am
At simplest, with seg2cat you could have:
mysite.com/group/template/category-nameOr, using the index template in /group/:
mysite.com/group/category-nameA bit more complex, but with a bit of jiggering you could also have:
mysite.com/group/category-name-1/category-name-2And have a list of entries that were assigned to both categories.
#14 / Mar 07, 2012 12:42pm
Thanks guys. I’ve built about 6 EE sites that use categories in various ways, so I’m used to the basics of URLs (at least at a basic level). Normally, if I were searching entries in a category, I’d end up with something like
mysite.com/group/template/category/category-name
and posts assigned to category-name would be listed on the page. How any of that relates to seg2cat I truly have no idea, though.
If urls like mysite.com/group/template/category/category-name are ok for your project, there is no need for seg2cat, but if you’re using categories in a situation where the urls have to be structured in a way that is different from EE’s defaults, seg2cat is a lifesaver.
#15 / Mar 07, 2012 4:33pm
Yes, I’d much prefer the kinds of URLs described above, so I’ll give it a go. I just wish the add-on’s documentation were a bit more descriptive. It doesn’t really give much of a clue to how to use the thing. Anyway, thanks for your explanations, guys. 😊