gma / nesta

File Based CMS and Static Site Generator
http://nestacms.com
MIT License
902 stars 121 forks source link

date in url seo #12

Closed rawsyntax closed 13 years ago

rawsyntax commented 13 years ago

Currently I'm not finding a way to have the date in the url for blog entries

Say I make an entry (filename: my-blog-entry.mdown)

currently the url is /my-blog-entry

I'd like to be able to do /2010/09/23/my-blog-entry

I had a look at the code myself.. and it appears this fix would take more than 5 minutes. Any plans to do this?

gma commented 13 years ago

Hi. I don't think it'd be particularly hard to do this; I'll have a crack at it tomorrow and blog how to do it if it comes out as easily as I suspect. Sorry I've not replied sooner; I've just got back from a week away.

Cheers, Graham

rawsyntax commented 13 years ago

have you had any luck with this yet?

gma commented 13 years ago

I've just been having a bit of a hack on it and I think I've got it going. I can certainly click round a site with it behaving it self.

All I need to do now is get it to you in a digestable manner (so I'm just tidying it up and working out how best to publish it – won't be long).

gma commented 13 years ago

Here you go. I'm toying with making a screencast/blog post, but in the meantime this gist should get you going:

http://gist.github.com/599418

You may also want to prevent Nesta from serving articles with dates at their default URL. You can do this by changing line 164 of the main app.rb file from this:

raise Sinatra::NotFound if @page.nil?

to this:

raise Sinatra::NotFound if @page.nil? || @page.date
rawsyntax commented 13 years ago

thanks! it works

gma commented 13 years ago

Cool. Incidentally, the reason that Nesta doesn't do this already is basically just because I'm not convinced it's a good idea.

I'd quite like the idea of showing a list of articles that were published in a given year at /2009/07 or simply /2010, but I don't think that the date in a blog post's URL is generally that helpful. I've never heard of any actual SEO benefit of doing it. I prefer using category pages and short (yet keyword rich) URLs, according to these ideas: http://www.wordtracker.com/academy/website-structure

That's not to say that you shouldn't be able to do it if you want to though, so I'll definitely be writing this up...

Let me know if you find any problems with it – I haven't written any tests for this new code.

gma commented 13 years ago

One last thing; I had a quick look at your blog and realised that I haven't really documented how to create nested URLs that don't live under a site's root. You've probably already twigged how to do it, but just in case...

If you create content/pages/foo and put content/pages/foo/bar.mdown in it, it'll be served from /foo/bar on your web site. You can create as many levels in the hierarchy as you like...

rawsyntax commented 13 years ago

Yeah, I think thats in there somewhere. I had considered creating directory structures to take care of putting the date in the url, but I figured that would be too messy to do

gma commented 13 years ago

Ah, sorry, I didn't mean you should make directories to put dates in, but rather just to organise your pages and to improve your SEO.

I can't really see the point of a date in the URL myself (and I bet Google can't either).