Best way to generate slugs (human-readable IDs) in Rails

You know, like myblog.com/posts/donald-e-knuth. Should I do this with the built in parameterize method? What about a plugin? I could imagine a plugin being nice for handling duplicate slugs, etc. Here are some popular Github plugins — does anyone have any experience with them? http://github.com/rsl/stringex/tree/master http://github.com/norman/friendly_id/tree/master Basically it seems like slugs are a totally solved … Read more

URL Slugify algorithm in C#?

So I have searched and browsed through the slug tag on SO and only found two compelling solution: Slugify and Character Transliteration in C# How to convert super- or subscript to normal text in C# Which are but partial solution to the problem. I could manually code this up myself but I’m surprised that there … Read more

Why do some websites add “Slugs” to the end of URLs? [closed]

Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it’s on-topic for Stack Overflow. Closed 9 years ago. Improve this question Many websites, including this one, add what are apparently called slugs – descriptive but as far as I can tell useless bits of … Read more

String slugification in Python

I am in search of the best way to “slugify” string what “slug” is, and my current solution is based on this recipe I have changed it a little bit to: s = ‘String to slugify’ slug = unicodedata.normalize(‘NFKD’, s) slug = slug.encode(‘ascii’, ‘ignore’).lower() slug = re.sub(r'[^a-z0-9]+’, ‘-‘, slug).strip(‘-‘) slug = re.sub(r'[-]+’, ‘-‘, slug) Anyone … Read more

PHP function to make slug (URL string)

I want to have a function to create slugs from Unicode strings, e.g. gen_slug(‘Andrés Cortez’) should return andres-cortez. How should I do that? Answer Instead of a lengthy replace, try this one: public static function slugify($text, string $divider = ‘-‘) { // replace non letter or digits by divider $text = preg_replace(‘~[^\pL\d]+~u’, $divider, $text); // … Read more

How does Stack Overflow generate its SEO-friendly URLs?

What is a good complete regular expression or some other process that would take the title: How do you change a title to be part of the URL like Stack Overflow? and turn it into how-do-you-change-a-title-to-be-part-of-the-url-like-stack-overflow that is used in the SEO-friendly URLs on Stack Overflow? The development environment I am using is Ruby on Rails, … Read more