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.

A slug is a part of a URL that makes it more human readable or SEO-friendly, but without necessarily being required by the web server. Slugs can be generated from a page title and are typically the last part of the url.

Example:

  • Page Title: c# - What's the difference between String and string? - Stack Overflow
  • Slug: whats-the-difference-between-string-and-string

The full URL including the slug is https://stackoverflow.com/questions/7074/whats-the-difference-between-string-and-string. Note that punctuation in the url is typically removed.

1108 questions
32
votes
3 answers

Convert non-ASCII characters (umlauts, accents...) to their closest ASCII equivalent (slug creation)

I am looking for way in JavaScript to convert non-ASCII characters in a string to their closest equivalent, similarly to what the PHP iconv function does. For instance if the input string is Rånades på Skyttis i Ö-vik, it should be converted to…
Max
  • 11,487
  • 26
  • 79
  • 129
28
votes
12 answers

How to create a unique slug in Django

I am trying to create a unique slug in Django so that I can access a post via a url like this: http://www.example.com/buy-a-new-bike_Boston-MA-02111_2 The relevant models: class ZipCode(models.Model): zipcode = models.CharField(max_length=5) …
mitchf
  • 3,147
  • 3
  • 21
  • 28
26
votes
2 answers

URL Friendly Username in PHP?

On my PHP site, currently users login with an email address and a password. I would like to add a username as well, this username they g\set will be unique and they cannot change it. I am wondering how I can make this name have no spaces in it and…
JasonDavis
  • 45,100
  • 92
  • 294
  • 508
25
votes
9 answers

django.db.utils.IntegrityError: UNIQUE constraint failed: rango_category__new.slug

I'm learning Django from Tango with Django but I keep getting this error when I type: python manage.py makemigrations rango python manage.py migrate This is the output: django.db.utils.IntegrityError: UNIQUE constraint failed:…
ArrowsX
  • 385
  • 1
  • 3
  • 8
24
votes
9 answers

Convert string into slug with single-hyphen delimiters only

I would like to sanitize a string in to a URL so this is what I basically need: Everything must be removed except alphanumeric characters and spaces and dashed. Spaces should be converter into dashes. Eg. This, is the URL! must…
Atif
  • 9,948
  • 19
  • 60
  • 95
22
votes
8 answers

Generate SEO friendly URLs (slugs)

Definition From Wikipedia: A slug is the part of a URL which identifies a page using human-readable keywords. To make the URL easier for users to type, special characters are often removed or replaced as well. For instance, accented characters…
GG.
  • 17,726
  • 11
  • 69
  • 117
19
votes
1 answer

Wordpress: How to get the tag's slug on the tag page

I'm on the tag.php page. How can I get its slug? single_tag_title() gets the title just fine, but the slug?
podcastfan88
  • 699
  • 2
  • 9
  • 23
17
votes
12 answers

How can I create a SEO friendly dash-delimited url from a string?

Take a string such as: In C#: How do I add "Quotes" around string in a comma delimited list of strings? and convert it to: in-c-how-do-i-add-quotes-around-string-in-a-comma-delimited-list-of-strings Requirements: Separate each word by a…
Shawn
  • 18,369
  • 19
  • 95
  • 151
17
votes
6 answers

ID + Slug name in URL in Rails (like in StackOverflow)

I'm trying to achieve URLs like this in Rails: http://localhost/posts/1234/post-slug-name with both ID and slug name instead of either http://localhost/posts/1234 or http://localhost/posts/post-slug-name (right now I have just slug name in URL,…
Vitaly
  • 2,449
  • 5
  • 28
  • 33
16
votes
2 answers

How to get attribute name instead of slug in variation?

I need to get attribute from woocommerce product variation. $terms = get_post_meta($value['variation_id'], 'attribute_pa_color', true); This code is giving me an attribute slug instead of name. How can I get attribute name? Thank you so much in…
Pupik
  • 381
  • 1
  • 2
  • 12
15
votes
4 answers

Should I create a slug on the fly or store in DB?

A slug is part of a URL that describes or titles a page and is usually keyword rich for that page improving SEO. e.g. In this URL PHP/JS - Create thumbnails on the fly or store as files that last section…
Guy
  • 59,547
  • 93
  • 241
  • 306
15
votes
4 answers

What is the alphanumeric id in a reddit URL?

What is the 7n5lu in the reddit URL http://www.reddit.com/r/reddit.com/comments/7n5lu/man_can_fly_if_you_watch_one_video_in_2 ...and how is it generated? Update: @Gerald, I initially thought this is some obfuscation of the id. It is just doing…
Shameem
  • 13,659
  • 13
  • 38
  • 42
15
votes
3 answers

Use Twig Extension in controller

I have a slugify method in an Twig Extension which i would like to use in some cases in a controller, f.e with redirects. Is there an easy way for this? How could i access functions from Twig Extensions in the controller? Or do i have to make the…
ivoba
  • 5,283
  • 4
  • 40
  • 50
14
votes
5 answers

Check if a string is a possible abbrevation for a name

I'm trying to develop a python algorithm to check if a string could be an abbrevation for another word. For example fck is a match for fc kopenhavn because it matches the first characters of the word. fhk would not match. fco should not match fc…
Björn Lindqvist
  • 16,492
  • 13
  • 70
  • 103
14
votes
3 answers

Using slugs in codeigniter

I have heard of people using slugs for generating clean urls. I have no idea how it works. Currently i have a codeigniter site which generates url's like this www.site.com/index.php/blog/view/7 From what i understand by maintaining a slug field it…
esafwan
  • 14,622
  • 30
  • 99
  • 154
1
2
3
73 74