DEV Community

Discussion on: Against Namespacing Personal Sites

Collapse
 
joelbonetr profile image
JoelBonetR 🥇

It's been called pretty links for some time.
The reason some sites don't add /blog/ into the URI is because the site itself is a blog.

By the other hand, adding year, month, day into the URL means you don't understand the basics. I mean, you can set your URLs like this on wordpress and many other sites and had some kind of sense on wordpress as it worked generating files for each entry/post.

Each part on the URL must be either a directory or a file, so what's the point on adding a folder called 2020, another one called september and another one called 10 just for storing here what?

Of course, you will store anything here, your data will be into the database and there's only a config into .htaccess and some controller using this URI to show one content or another (or some other kind of mapping between this false URI and your content).

The way the major part of the reliable web is managed ( domain/directory/content) is the best for users too, which can know quickly what they are about to open, this links are simple and clean, that's why they're called "pretty links" or similar.

Of course there's no point on adding year month day into your URI related to SEO, it works matching the uri and the content apart from context and much more points.

Where to add a directory into your URL? When it's needed;
if your entire website is a blog, there's no point on adding a subdomain or directory called blog, for example.

If your site is about something else but you have a blog, you must add either a subdomain blog.domain.com or a directory domain.com/blog.
In this case it has SEO implications, which adding a directory makes the main domain stronger while adding a subdomain it's treated more like a different tool (which can be true and realistic on many sites)

Collapse
 
ohryan profile image
Ryan

By the other hand, adding year, month, day into the URL means you don't understand the basics.

I strongly disagree.

so what's the point on adding a folder called 2020, another one called september and another one called 10 just for storing here what?

The 2020 "folder" will show you all posts from 2020. The 2020/10/ path shows you all posts from October 2020 and 2020/10/11 retrieves all posts from 11th October 2020. It's greate way to get an overview of posts from a specific time in the history of a blog.

Collapse
 
joelbonetr profile image
JoelBonetR 🥇 • Edited

I may not explained well the concept.
I mean that you don't have a directory called 2020, you will have N DB Rows of posts where their date_add or publish date is a datetime type field.

That makes you able to show all posts from 2020 by simply querying

SELECT * FROM posts WHERE date_add >= '2020-01-01' ; 

Same for specific month, day, hour, minute...

There's no data stored into physical or logic folders, all data is usually set inside the database instead, so why do you want to add and map an inexistent server directory?

You can also think into media which is stored on the server, well that's another story, you'll also store into the DB the URL of that resource and of course, the date_add so same here. Moreover if you want to distribute your blog you'll need to store your media into something more "open" such a CDN like storage service (look at Google Cloud Storage for example) so that will not be an issue as you only will need to update your DB rows with this new URLs and that's all. If you rely on server directories it will be a massive mess to distribute.

Thread Thread
 
ohryan profile image
Ryan

There's no data stored into physical or logic folders, all data is usually set inside the database instead, so why do you want to add and map an inexistent server directory?

Well it's not a server directory, it's a rewrite rule that generates a DB query.

The original purpose of this style of URL structures is to have a human navigable path (which has the side effect of also helping search engines, especially 15-20 years ago).

By "human navigable" I mean that a human can easily decompose the URI back to the site root and get meaningful content along the way.

  1. /2020/09/12/some-blog-post is a blog post posted today
  2. /2020/09/12/ remove the post slug and now you've got all posts from today
  3. /2020/09/ remove the day and now you've got all posts from this month
  4. /2020/ remove the month and now you've got all posts from the year.
  5. / remove the year and now you've got all posts on the blog.

Without this structure a human would have to perform a search typically with an ugly URL with a bunch of query params that are difficult for a human to type easily. Sure you could dynamically generate a link to archives that fills in the params but you don't really want to pollute your pages with links for every year, month and day you've posted content.

This URL structure is an artifact from the early days of blogging when we had much debate exactly like this.

Thread Thread
 
joelbonetr profile image
JoelBonetR 🥇

Yup, of course I know and understand the origin. Moreover there was some blogging tools that generates physical/logical server directories with text files to store the data.

Nowadays you don't need those params, and the average user hardly will be editing the URL so you build usable UIs with nice options to search and filter through your data to provide content to your users/customers. That implies providing links that shows correctly and on a non-verbose way what it's all about. Specially because most of time the URL string is shown break so you can not read it all.

Moreover if you provide a good search in between your data (title, content, category, tags, media alts and so) it will be much more fast than giving options to filter only (by year, category and tags).

Also for RSS sharing getting a link like:
domain/post-title

Will be preferred in comparison to:
domain/year/month/day/post-title