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.

1272 questions
5
votes
2 answers

PHP slug function for all languages

I'm wondering if there is a simple function/code that can take care of creating a slug from a given string. I'm working on a multilingual website (English, Spanish, and Arabic) and I'm not sure how to handle that for Spanish and Arabic…
Kareem JO
  • 191
  • 1
  • 12
5
votes
3 answers

Generating doctrine slugs manually

I'm using sluggable behavior in my Symfony2 project, but now I would like to make many slugs for one page, based on different texts (current title, old title(s), users text from form input), and keep it in another table. And my question is - how to…
Radzikowski
  • 2,377
  • 4
  • 27
  • 39
5
votes
1 answer

getting error with django slugify

I am trying this from django.utils.text import slugify In [8]: mystr = "This is john" In [9]: slugify(mystr) and i am getting this error TypeError: must be unicode, not str if i use this from django.template.defaultfilters import slugify then it…
fdsgds
  • 129
  • 6
5
votes
4 answers

Better to save a slug to the DB or generate dynamically?

I am working on a django project and would like to include a slug at the end of the url, as is done here on stackoverflow.com: http://example.com/object/1/my-slug-generated-from-my-title The object ID will be used to look up the item, not the slug…
thornomad
  • 6,707
  • 10
  • 53
  • 78
5
votes
4 answers

Make the prepopulated slug field as readonly in Django Admin

I want to make the slug field as read_only depending on the other field value like "lock_slug". Means There will be Two conditions. 1) When value of "lock_slug" is false then the slug field directly prepopulated from the field…
Meenakshi
  • 259
  • 5
  • 19
5
votes
1 answer

Bulk rewrite post slugs based on custom field value in Wordpress

Basically I have a custom post type setup called "Parts" with over 5,000 posts currently in it. There are a number of custom fields associated with each part, including a "part number". Currently, the URL for each part…
Trevor Gehman
  • 4,645
  • 3
  • 22
  • 25
5
votes
1 answer

Understanding slug positioning by different sites

While trying to understand how to create a better URL for ease of user and not compromising on SEO, I was looking at the structure for different sites. I have a few queries related to the below ones: Amazon ->…
Ethan
  • 4,915
  • 1
  • 28
  • 36
4
votes
4 answers

How do I enhance slugify to handle Camel Case?

I'd like to write a JavaScript function to slugify a string, with one more requirement: handle Camel Case. For example, thisIsCamelCase would become this-is-camel-case. How do I modify a function like this to do so? EDIT Added full, answered…
Matt Norris
  • 8,596
  • 14
  • 59
  • 90
4
votes
1 answer

Heroku App Crashed

I'm trying to figure out why my app crashed, my slug size is very large 54mb but on my computer the folder size is like 3mb, here is my log file: (Of course rails server runs perfectly fine, but can't figure out the heroku…
eWizardII
  • 1,916
  • 4
  • 32
  • 55
4
votes
2 answers

How to auto-update the slug field in Django admin site?

I know how to auto-populate the slug field of my Blog application from post's title, and it works fine. But if I edit the title the slug field is not changing. Is there any way to have it updated automatically? I use Django's admin site. Thanks.
Omid Shojaee
  • 333
  • 1
  • 4
  • 20
4
votes
3 answers

Heroku Slug Size too large - nodejs

This is my first heroku app... and I see that my heroku slug size is 296MB... getting uncomfortably close to the fast 300MB boot time. This is a puppeteer app with ejs, path, and express installed. I have a bunch of static files but they don't seem…
Moshe
  • 353
  • 1
  • 3
  • 10
4
votes
0 answers

How to change default page slug?

I have a CPT called jobs and a page named Job Apply. I am trying to achieve something like below url: http://example.com/job-slug/apply Where, job-slug can be any job. i.e Programmer, Developer etc.. On clicking job's apply button, it should open…
4
votes
1 answer

Having Problem in Creating slugs for Japanese language using LARAVEL

I am creating this app using laravel. It requires to have Japanese slugs because almost all of the content is in Japanese language. I tried to use several packages but none of them provide good support to Japanese language. So, I am trying to create…
user8232211
4
votes
2 answers

Is there any way to create dynamic slugs with Gatsby using a template component / page?

I am quite new to Gatsby and I'm wondering if I can create custom routes (slugs) as templates. The use case would be: Access /articles/name-of-the-article route Serve component Article.js populated with the information retrieved from an API (i.e…
Mihai Moraru
  • 404
  • 4
  • 12
4
votes
1 answer

Javascript Slug working for non latin characters also

Basically I found a slug function which looks like this: function slug(string) => { return string.toString().toLowerCase() .replace(/\s+/g, '-') .replace(/[^\w\-]+/g, '') .replace(/\-\-+/g, '-') .replace(/^-+/,…
paulalexandru
  • 9,218
  • 7
  • 66
  • 94