DEV Protip: Set the Slug of your posts

TL;DR

When creating a post, set it’s title to the slug you like and then publish it. You can change the title to the desired one later.

Check out the slug of this post ^ up there. Do you see it?

The slug should have been dev-protip-set…


This content originally appeared on DEV Community and was authored by Siddharth

TL;DR

When creating a post, set it's title to the slug you like and then publish it. You can change the title to the desired one later.

Check out the slug of this post ^ up there. Do you see it?

The slug should have been dev-protip-set-the-slug-of-your-posts or something like that. But instead, it is dev-tip-set-slug, which is much more readable. Here, I'll show you how to set the slugs of any post.

Note: This won't work for published posts. You have to do this when you create a new post or edit a draft.

  1. Create a Post

    create-post

    Click on that button at the top right
  2. Set the title of the post as the slug

    set-slug

    Choose a small, appropriate slug
  3. Write your content and publish the post

    You can continue writing your post's contents. Just make sure to not change the title. Once you finish, you can publish the post.

    Now, the slug will be generated from the post title.

    view-slug

  4. Fix the title

    Now, you edit the post and set the proper title, then you can click Save Changes. The trick here is that if you edit the title, the slug will not be recalculated.

  5. Done!

    You can continue making changes to the title, body and tags, but the slug will never change. This is supposed to be a bug, but it can be sort of useful.

    If you want, you can view the post which I showed you in this post here


This content originally appeared on DEV Community and was authored by Siddharth


Print Share Comment Cite Upload Translate Updates
APA

Siddharth | Sciencx (2021-07-08T02:57:07+00:00) DEV Protip: Set the Slug of your posts. Retrieved from https://www.scien.cx/2021/07/08/dev-protip-set-the-slug-of-your-posts/

MLA
" » DEV Protip: Set the Slug of your posts." Siddharth | Sciencx - Thursday July 8, 2021, https://www.scien.cx/2021/07/08/dev-protip-set-the-slug-of-your-posts/
HARVARD
Siddharth | Sciencx Thursday July 8, 2021 » DEV Protip: Set the Slug of your posts., viewed ,<https://www.scien.cx/2021/07/08/dev-protip-set-the-slug-of-your-posts/>
VANCOUVER
Siddharth | Sciencx - » DEV Protip: Set the Slug of your posts. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/07/08/dev-protip-set-the-slug-of-your-posts/
CHICAGO
" » DEV Protip: Set the Slug of your posts." Siddharth | Sciencx - Accessed . https://www.scien.cx/2021/07/08/dev-protip-set-the-slug-of-your-posts/
IEEE
" » DEV Protip: Set the Slug of your posts." Siddharth | Sciencx [Online]. Available: https://www.scien.cx/2021/07/08/dev-protip-set-the-slug-of-your-posts/. [Accessed: ]
rf:citation
» DEV Protip: Set the Slug of your posts | Siddharth | Sciencx | https://www.scien.cx/2021/07/08/dev-protip-set-the-slug-of-your-posts/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.