Let’s say you have your site running with WordPress, which is very likely now that WordPress runs 25% of the web. But along with your site you also have a blog and want to use a separete URL, something like:
www.yoursite.com/blog/ and you want your posts to be something like
Lucky for you, WordPress can add ‘blog’ to your links.
This is the aprouch we use here in Quema Labs, all our posts are prefixed with the word /blog/ and I want to show you how to do that.
First, go to your Permalinks settings in your Admin Panel > Settings > Permalinks, on Custom Structure you will see something like this:
So let’s add at the begining the word ‘/blog‘, it will look like this:
That will prefix all your blog posts with ‘/blog/’ but now we also want the categories and tags URLs working the same, so take a loox at the boxes below, probably they are empty, so let’s fill them with:
This time you don’t have to add a slash at the begining:
Now click Save Change and that’s it!.
Custom Post Type
If you are using Custom Post Type, they will also have that ‘/blog’/ in the URL, to avoid that you need to add a new parameter when you register the post type.
For example here in Quema Labs we have a Custom Post Type called ‘theme‘ to show our themes on the site. If we go to the code where we register this CPT and add this:
register_post_type( 'my_post_type', array( [...] 'rewrite' => array( 'slug' => 'theme', 'with_front' => false ), [...] ) );
The important thing here is adding the option ‘with_front‘ to false. The ‘slug‘ will be different for your CPT.
With that in place we avoid the ‘/blog/‘ on our theme’s URLs.
Remember to save your permalink settings in Admin Panel after changing your rewrite rules!
18 Replies to “How to add ‘/blog/’ in front of your URL”
This is a really great tip for WordPress beginners. Many people don’t know that it’s that simple and easy.
Thousands of people don’t know this tip, really good tips for wordpress beginner user
There doesn’t seem to be a redirect from the old posts to the new posts. Is there a way to automatically do that?
You can install a plugin like SEO Redirection Plugin.
It will allow you to do 301 redirects on a per page/post basis or even using REGEX.
I just installed it and I am going to put blog in front of my URLs. Wish me luck 🙂
Thanks for a beginner in wordpress !
The step with changing category/tag base after changing the post base is not needed, categories and tags archives will be automatically prepended with the post base.
How to change same thing in blogger domain?
I want to change my domain like .com/news or
.com/category. Please help
I’m sorry but I’m not sure how to achieve that on Blogger.
Thanks for this clear tutorial, I applied used in my wordpress site and worked more than well.
Just what i needed…thank you!
Hi, when a do this process, the /blog does not appears in the breadcumbs. What can I do?
I want my blog:
and the breadcumbs:
Home > Blog > Category > Post1
How can I add the > Blog to my breadcumbs?
I guess it does not appear because / blog is artificially configured. Is there any way to make it hierarchical?
Thank you!!!! much appreciated
Great article, Thank you.
This is a really great tip, But Why use a blog
Thousands of people don’t know this tips, really very good tips for wordpress users.
I have followed the above steps, which is working fine and automatically adding /blog/ before all custom post types URL. I just want to exclude /blog/ from custom post type. Any idea how to achieve it.
Gracias por el Tutorial.
I was just looking for this solution.