Questions tagged [slug]

part of a URL that makes it more human readable or SEO-friendly, but without necessarily being required by the web server.

Filter by
Sorted by
Tagged with
712votes
13answers
227kviews

What is a "slug" in Django?

When I read Django code I often see in models what is called a "slug". I am not quite sure what this is, but I do know it has something to do with URLs. How and when is this slug-thing supposed to be ...
user avatar
  • 18.7k
371votes
26answers
224kviews

Turn a string into a valid filename?

I have a string that I want to use as a filename, so I want to remove all characters that wouldn't be allowed in filenames, using Python. I'd rather be strict than otherwise, so let's say I want to ...
user avatar
  • 4,742
265votes
21answers
43kviews

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-...
user avatar
  • 12.1k
255votes
3answers
974kviews

Remove all special characters from a string [duplicate]

I am facing an issue with URLs, I want to be able to convert titles that could contain anything and have them stripped of all special characters so they only have letters and numbers and of course I ...
user avatar
  • 4,342
240votes
9answers
136kviews

How do I create a slug in Django?

I am trying to create a SlugField in Django. I created this simple model: from django.db import models class Test(models.Model): q = models.CharField(max_length=30) s = models.SlugField() ...
user avatar
  • 5,901
202votes
26answers
310kviews

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?
user avatar
  • 10.4k
195votes
23answers
180kviews

How to convert a Title to a URL slug in jQuery?

I'm working on an app in CodeIgniter, and I'm trying to make a field on a form dynamically generate the URL slug. What I'd like to do is remove the punctuation, convert it to lowercase, and replace ...
user avatar
  • 40.1k
122votes
11answers
85kviews

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....
user avatar
  • 7,177
113votes
14answers
44kviews

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

Many websites, including this one, add what are apparently called slugs - descriptive but as far as I can tell useless bits of text - to the end of URLs. For example, the URL the site gives for this ...
user avatar
  • 185k
92votes
5answers
44kviews

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# ...
user avatar
  • 59.7k
67votes
12answers
52kviews

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. ...
user avatar
  • 79.3k
45votes
8answers
24kviews

How to make Django slugify work properly with Unicode strings?

What can I do to prevent slugify filter from stripping out non-ASCII alphanumeric characters? (I'm using Django 1.0.2) cnprog.com has Chinese characters in question URLs, so I looked in their code. ...
user avatar
  • 80.9k
45votes
3answers
35kviews

Why SlugField() in Django?

Django has models.SlugField() which helps us to create some cool looking urls. My question is why specifying it as a field suppose I have this model class Blog(models.Model): title = models....
user avatar
  • 3,468
44votes
4answers
24kviews

Java code/library for generating slugs (for use in pretty URLs)

Web frameworks such as Rails and Django has built-in support for "slugs" which are used to generate readable and SEO-friendly URLs: Slugs in Rails Slugs in Django A slug string typically contains ...
user avatar
  • 47k
41votes
6answers
25kviews

Is there an easy way to populate SlugField from CharField?

class Foo(models.Model): title = models.CharField(max_length=20) slug = models.SlugField() Is there a built-in way to get the slug field to autopopulate based on the title? Perhaps in the ...
user avatar

15 30 50 per page
1
2 3 4 5
79