WordPressでカテゴリーベースの接頭辞を変更したいですか?
初期設定では、WordPressはすべてのカテゴリーページのURLのプレフィックスとして/category/を自動的に追加します。しかし、カテゴリーベースの接頭辞を簡単に変更したり、完全に削除したりすることができます。
この投稿では、WordPressでカテゴリーのベースプレフィックスを変更する方法を紹介します。
カテゴリープレフィックスとは?変更すべきか?
WordPressサイトの各カテゴリは、独自のページとRSSフィードを取得します。カテゴリーのアーカイブページにアクセスすることで、そのカテゴリーで投稿されたすべての投稿を表示することができます。
初期設定では、WordPressはカテゴリーページのURLのベース接頭辞として「カテゴリー」を追加します。これは、カテゴリーやタグアーカイブからページや投稿を区別するのに役立ちます。
例えば、「ニュース」というカテゴリーがある場合、そのURLは次のようになります:
http://example.com/category/news/
同様に、WordPressもタグアーカイブのURLにタグ接頭辞を追加します。
http://example.com/tag/iphone/
このSEOフレンドリーなURL構造は、ユーザーや検索エンジンが、どのようなページにアクセスしているのかを理解するのに役立ちます。
ほとんどのサイトでは、ベースプレフィックスをすべて変更する必要はありません。ただし、ニッチなサイトを作成していて、カテゴリーに別の単語やフレーズを使用したい場合は、カテゴリーのベース接頭辞を変更して反映させることができます。
WordPressでカテゴリーのベースプレフィックスを変更する
WordPressでカテゴリーのベースプレフィックスを変更するのはとても簡単です。
WordPressダッシュボードから設定 ” パーマリンクのページにアクセスし、「オプション」セクションまでスクロールダウンする必要があります。
カテゴリーベース」フィールドでは、カテゴリーベースオプションの隣に使用したい接頭辞を入力できます。必要に応じて、タグベースの接頭辞を変更することもできます。
例えば、新しい接頭辞として「topics」を追加することができます。この場合、カテゴリーのURLは次のようになります:
http://example.com/topics/news/
変更を保存」ボタンをクリックして、設定を保存することを忘れないでください。
URLからカテゴリー・ベース接頭辞を削除する
多くのユーザーから、WordPressのURLからカテゴリーベースの接頭辞を完全に削除したいとの問い合わせがありました。これにより、カテゴリーURLは以下のようになります:
http://example.com/news/
これは良いアイデアではないので、カテゴリーベースの接頭辞は削除しないことをお勧めする。
カテゴリーベースのプレフィックスは、ユーザーと検索エンジンの両方が投稿/ページとカテゴリーを区別するのに役立ちます。プレフィックスを削除するとURLが曖昧になり、ユーザーエクスペリエンスやWordPressのSEOにとって良くありません。
また、様々なWordPressプラグインで技術的な問題に遭遇することもあります。例えば、カテゴリーとページが同じ名前の場合や、個別投稿のURL構造として%postname%を使っている場合、サイトが無限リダイレクトループに陥り、ページが読み込まれなくなります。
しかし、それでもこれを行いたい場合は、All In One SEO (AIOSEO)プラグインを使用することができます。
WordPressのための最高のSEOプラグインであり、検索エンジンのためにあなたのサイトを最適化することは非常に簡単です。さらに、ボタンをクリックするだけで、カテゴリーベースの接頭辞を取り除く設定もできます。
このチュートリアルでは、カテゴリーベースを削除する機能や、リダイレクトマネージャーやリンクアシスタントのような他の強力なオプションが含まれているため、AIOSEO Proライセンスを使用します。AIOSEOには無料版もあります。
まず、AIOSEOプラグインをインストールし、有効化する必要があります。詳しくはWordPressプラグインのインストール方法をご覧ください。
有効化すると、AIOSEOセットアップウィザードが表示されます。Let’s Get Started」ボタンをクリックしてください。詳しくは、All In One SEO for WordPressの設定方法をご覧ください。
次に、WordPressの管理画面からAll In One SEO Search ” 外観に移動し、「タクソノミー」タブをクリックします。
その後、カテゴリーセクションに移動し、「詳細」タブに切り替えます。ここから、「カテゴリーのベースプレフィックスを削除する」オプションの「はい」をクリックします。
完了したら「変更を保存」ボタンをクリックするのをお忘れなく。
カテゴリー・ベースプレフィックス変更後のリダイレクト設定
新規WordPressサイトでカテゴリーベースのプレフィックスを変更または削除する場合は、何もする必要はありません。しかし、既存のサイトでこれを行う場合、古いカテゴリーページにアクセスしたユーザーには404エラーが表示されます。
この問題を解決するには、リダイレクトを設定して、検索エンジンと一般の訪問者の両方がサイトの正しいカテゴリーページに正しくリダイレクトされるようにする必要があります。
WordPressでリダイレクトを設定する最も簡単な方法は、All In One SEO(AIOSEO)プラグインを使用することです。
まず、WordPressの管理画面からAll In One SEO ” Redirectsに移動し、’Activate Redirects’ボタンをクリックします。
有効化したら、「リダイレクト」タブでリダイレクトを設定することができます。
リダイレクトしたいURLを「ソースURL」フィールドに、リンクの新しい場所を「ターゲットURL」フィールドに入力するだけです。
Redirct Typeについては、ドロップダウンメニューから「301 Moved Permanently」を選択することができます。これにより、古いカテゴリーページは永久に新しい移動先に移動します。
完了したら「Add Redirect」ボタンをクリックするのをお忘れなく。
詳しくは、WordPressで301リダイレクトを作成するための初心者ガイドをご覧ください。
これで、すべてのユーザーと検索エンジンが、新しいカテゴリー接頭辞を使って正しいURLにリダイレクトされます。
この投稿がWordPressでカテゴリーベースの接頭辞を変更する方法を学ぶのにお役に立てば幸いです。WordPressのTips、トリック、ハックのリストやオンラインストアを始める方法もご覧ください。
If you liked this article, then please subscribe to our YouTube Channel for WordPress video tutorials. You can also find us on Twitter and Facebook.
Syed Balkhi says
Hey WPBeginner readers,
Did you know you can win exciting prizes by commenting on WPBeginner?
Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
You can get more details about the contest from here.
Start sharing your thoughts below to stand a chance to win!
Afaq Ahmad Khan says
When i set “Category base” with “%category%” in permalink it works fine but all other posts and page going in 404.
I have to set “Category base” with “%category%”. How can it be achieve?
Aasif Ganaie says
I want to change “category” base in “news” as well as “tag” into “topic” on a WordPress website. Will this method work in Yoast redirects as I don’t want to use a separate plugin?
Meghan says
Instead of having URL.com/tag.. I want to change it to URL.com/category/tag but I can’t seem to do this. Can you easily explain how to achieve this?
Paul Minors says
Hi there. Great article. I’m looking at doing something similar, but I’m not changing the category or tag base. I’m changing the base of “portfolio” pages. There isn’t an option to edit the case in the permalink settings. Is there another way to edit bases in my wordpress files?
Karunakar says
How to add a custom text to tag url slug?
For example:
my tag_base is “beginner”
my tag is: “wp”
Then normally url becomes: example.com/beginner/wp
Here I want to add text “help” to the slug of tag “wp” to make url as:
example.com/beginner/wp-help
I don’t want to go with a single tag slug edit. I want to append “-help” to all existed tags slugs and upcoming tags.
How can i do it?
Please help.
Thank you.
spezially says
Hi ,
what’s the easiest way if I wanted to have my general post page + all the posts that refer to the general post category bring up a prefix (ex.: news.example.com . news.example.com/single-post )
?
so far the only solution I can think of is a 301 redirect in htaccess but I’m looking for something smoother….
Conal Stubbs says
I’ve found a somewhat odd way of removing the category part.
Just to explain, I’m creating a portfolio site with a category called ‘blog’ for blogposts / latest news and one called ‘work’ for completed design projects. Obviously the desired effect is to have the url as example.co.uk/blog (or work) rather than example.co.uk/category/blog, which looks just a bit naff I’m sure you’ll agree.
By simply putting a full stop in the category base entry field WordPress seems to ignore this requirement in the url and creates the leaner, cleaner version that was wanted.
Has anyone else seen this before? Do they know of any issues with it? I’m just getting to grips with WordPress having taught myself HTML, CSS and PHP, so I’ve only tried it on a local setup and with the twenty eleven theme.
WPBeginner Support says
This is an interesting approach. Did you consider using category archive templates, like category-blog.php and category-work.php? After using these templates you can use WordPress seo plugin to remove category slug from url and you will get your blog posts on example.com/blog and Work posts on example.com/work.
管理者
ashley says
perfect. thanks!
dinesh kumar says
it’s working but only one category not all category
i am use another category page will get a 404 (not found) error when trying to access the page again.
please update here
I want url overwriter
Santiago says
In this blog did you have problems? I can see that you remove the category base and looks pretty good. Could tell us how you do this?
WPBeginner Support says
If you are using WordPress SEO you can go to SEO » Permalinks check the box that says Strip the category base (usually /category/) from the category URL.
管理者
iAn says
I updated my WordPress SEO Plugin today and I got this message:
“The feature for stripping the category base will be removed in version 1.6 of WordPress SEO. We suggest using FV Top Level Categories if you insist on keeping this but do know that the feature is very error prone and not that important for your SEO.”
I guess you are using such feature too.
I worry that I will lose ranking if I “unstrip” the category in the URL. Any suggestion for this?
Arup Ghosh says
Thanks to SEO plugins like yoast, they have added an option for this on their current version.
gnuboss says
Thanks for the info, this is a quick and simple, although often overlooked way to sort the category and tag base issues out..
To entirely remove the Category base I used to use a plugin called WP No Category Base which worked well, but can cause problems when you have a page and category with the same name – E.g. Page = Hosting (domain.com/hosting/) and a Category = Hosting (domain.com/hosting/) – but using .html suffix may help — but there are bound to be implications.
web design cheltenham says
I always like to use the .html suffix as well as changing the prefix – thanks for sharing – a simple but effective technique!
Name Removed [TOS Violation] says
If you want to do this, you should probably do this right when you begin your blog.
Otherwise, search engines which have indexed your
example.com/tags/some-tag
page will get a 404 (not found) error when trying to access the page again.
Some SEO plugins handle this case and give a 302 (redirect) status when you change a permalink, but I’m not sure about tag URLs.
Nimit Kashyap says
I didn’t know that it was so easy to change.