Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow the use id's in the permalink url. #405

Closed
wants to merge 9 commits into from
Closed

Conversation

kf8a
Copy link

@kf8a kf8a commented Mar 3, 2014

I am using publify as a log and I have users that like to use the current date as the title. Sometimes this results in multiple articles with the same title on the same day. The default permalink url will return the first article. By allowing the use of the id in the permalink specification it becomes possible to distinguish between the articles. This might be too specific a use case to merge but I wanted to raise the issue.

@yaf
Copy link

yaf commented Mar 3, 2014

It's not a really good idea to expose ID. This field is for internal use only. But perhaps we can:

  • list all articles that match with a title
  • add a counter or something like that at the end of "date title"...

But perhaps other are ok to merge this.

@mvz
Copy link
Member

mvz commented Mar 4, 2014

The code that creates the permalink slug from the title should ensure uniqueness. The problem is of course that this uniqueness is only actually needed if two articles containing the same title fall on the same day. I don't think that's a problem: I'm fine with the following urls:

/2013/01/13/havent-blogged-in-a-long-time
/2014/02/14/havent-blogged-in-a-long-time--2

On the same day, we would get:

/2014/03/04/on-a-roll
/2014/03/04/on-a-roll--2
/2014/03/04/on-a-roll--3

@kf8a
Copy link
Author

kf8a commented Mar 4, 2014

that sounds like a better idea. I can write something up and resubmit.

@fdv
Copy link
Member

fdv commented Mar 4, 2014

Hello,

Everybody does not use date based permalinks (I don't).

@yaf and I have been discussing that point this morning, and we think that the permalink itself should be unique.

In case of a duplicate permalink, we have 2 solutions:

  1. prepend the post id to the permalink 12345-my-cool-post, but it breaks the idea of "nice permalinks"
  2. append a 2, 3, 4, 5... to the post like my-cool-post-2. The only problem: you add more database queries since you need to check that my-cool-post-2 is free, and if not my-cool-post-3 etc...

I'd go with 2 anyway, and since cool URIs don't change only start using that on new posts (which means that it should only be applied to post being published for the first time OR that were withdrawn) which add some complexity

@mvz
Copy link
Member

mvz commented Mar 4, 2014

Yes, option 2) is basically what I was trying to describe. The friendly_id gem provides this method of permalink creation (called 'slug' in friendly_id terms).

@fdv
Copy link
Member

fdv commented Mar 4, 2014

In an ideal world, the permalink generator would use a stop words file in the language the blog is configured to remove all stop words from the perma.

In this world, when I need to optimize a slug (Wordpress word BTW), I do it myself :)

@kf8a
Copy link
Author

kf8a commented Mar 4, 2014

Would appending a hash to the second article be acceptable /my-cool-post-eb1a3227cdc3fedbaec2fe38bf6c044a ? That way it would only have to check for uniqueness and not for the next id the sequence.

@randomecho
Copy link
Contributor

How about the date in YYYYMMDD format instead of the hash idea? That would look a little neater than a hash and add a little more semantic info.

/starting-again-20140305

@fdv
Copy link
Member

fdv commented Mar 4, 2014

nah, just 2, 3.... Keep it straight simple please.

@kf8a
Copy link
Author

kf8a commented May 4, 2014

sorry about the absence, got busy with other stuff. I'm going to close this and reopen in a bit from a feature branch so that the pull request is not so noisy.

@kf8a kf8a closed this May 4, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants