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
9
votes
1 answer

How to make and store slug for post title?

I use MongoDB/mongoose for storing blog posts with the following schema: PostSchema = mongoose.Schema({ title: {type: String}, body: {type: String} }); Now my post urls looks like the following:…
Erik
  • 11,695
  • 42
  • 119
  • 194
9
votes
2 answers

How to convert super- or subscript to normal text in C#

I'm writing a slug generator for making nice urls. I'd like to convert m² to m2, but in a generic way that does this for all superscript (or subscript), not just a simple replace statement. Any ideas?
Jorrit Salverda
  • 645
  • 7
  • 13
9
votes
5 answers

Laravel Slugs with Str::slug

Looking at Str::slug for my frontend URL generation but just wondering how you guys go about implementing it with routes etc, for example, how would you guys go about changing http://www.example.com/courses/1 to…
Gareth Daine
  • 3,496
  • 4
  • 38
  • 63
8
votes
3 answers

How to add the slug to all Link generation in an asp.net core website?

I need to be able to control the links being generated by my Url.Content("~") call to be able to accept a Slug in the beginning of the link. Basically the hosting URL will be behind a Load-balancer and may be at the root level or behind a friendlier…
ewassef
  • 181
  • 1
  • 11
8
votes
2 answers

Canonical links and 301 Redirect if URL doesn't match slug

I am trying to implement a URL scheme similar to stack overflow's in django/python. E.g. the pk is stored in the URL along with a slug of the title so for this question (id #4787731) the URL…
Ryan
  • 22,869
  • 23
  • 81
  • 126
8
votes
1 answer

wordpress fishpig magento installation - getPostListHtml()

I have a wordpress installation on my magento store utilizing the 3rd party module fishpig. I have a page called list.phtml which posts all the content from a category using $this->getPostListHtml() I added another div and replicated it but now it's…
thismethod
  • 523
  • 4
  • 23
8
votes
8 answers

creating unique page title slugs php

I have a function for creating unique slug for a page title. It checks if the slug is available in the pages table then creates a unique slug by adding a '-int' accordingly. The function works fine for the first three entries eg for 'test slug'…
bStaq
  • 121
  • 1
  • 2
  • 7
8
votes
1 answer

Symfony 2 - Sluggable not set when using form

I am trying to use the Sluggable behaviour from the Doctrine Extensions bundle: http://gediminasm.org/article/sluggable-behavior-extension-for-doctrine-2 I have set up a sluggable field in my entity using annotation but the value does not get set…
Dan
  • 5,311
  • 6
  • 34
  • 52
7
votes
4 answers

What is the best way to store a unique URL Slug?

I'm trying to generate some url 'slugs' for my website. It's based upon a single piece of user generated text. Now, i have made my own slug method, so i'm not after some code for that. What i'm wondering is where is the best place to determine if…
Pure.Krome
  • 78,923
  • 102
  • 356
  • 586
7
votes
1 answer

Cleaning form data in Django

How can i clean and modify data from a form in django. I would like to define it on a per field basis for each model, much like using ModelForms. What I want to achieve is automatically remove leading and trailing spaces from defined fields, or turn…
Josh Hunt
  • 12,949
  • 26
  • 73
  • 96
7
votes
7 answers

T-SQL function for generating slugs?

Quick check to see if anyone has or knows of a T-SQL function capable of generating slugs from a given nvarchar input. i.e; "Hello World" > "hello-world" "This is a test" > "this-is-a-test" I have a C# function that I normally use for these…
Jeremy Cade
  • 1,351
  • 1
  • 17
  • 26
7
votes
2 answers

Using slugs in laravel 5?

I have made eloquent-sluggable work on my app. Slugs are saved just fine. Buuuut... How do I use it to create a pretty url? If possible, I would like to use them in my url instead of ID numbers.
MartinJH
  • 2,460
  • 5
  • 31
  • 44
7
votes
5 answers

slug field on flask

I want to create a slug field stored in database. I searched and I found http://flask.pocoo.org/snippets/5/ but I'm having trouble integrating the code in my app. This is my modele.py: from unicodedata import normalize def slugfy(text,…
anouar
  • 115
  • 1
  • 8
7
votes
2 answers

Displaying both slug and ID in URL, but route by ID only in Django

What I'm trying to achieve is: my News app should display a slug, but only query the article by ID in the form of /news/24/this-is-the-slug Unfortunately I'm getting a NoReverseMatch: Reverse for 'news_detail' with arguments '('',)' and keyword…
weeheavy
  • 223
  • 3
  • 17
7
votes
4 answers

Make a post slug unique

I got few functions in placed which is not working as I wanted. The slug is automicatlly created on the fly depend on the post title. Example: If a post title is "test" then the slug will be "test" My problem is that, what if theirs duplicate…
Johny
  • 371
  • 1
  • 5
  • 14