Breadcrumbs not working correctly for subfolder install
-
Hi,
It looks like Yoast isn’t correctly recognising that WordPress is installed in a subfolder (example.com/blog/). So the Yoast breadcrumbs don’t show the true homepage at all, and ‘home’ links to the subfolder URL.
So you get:-
Home (example.com/blog/) > Category > Post Name
When it should be:-
Home (example.com) > Blog (example.com/blog/) > Category > Post NameThere doesn’t appear to be any setting for this, so how do I get it to properly reflect the structure of the site?
-
In your specific case, Yoast SEO does not recognize your root domain (example.com) as Home in the breadcrumb structure. It is because you’ve WordPress running in a subfolder (example.com/blog) which is actually a Home where the Yoast SEO plugin is installed. Breadcrumb structure thus generates relative to this subfolder installation.
That’s my point – it doesn’t work correctly ??
So how do I get it to properly reflect the structure of the site?
Hi,
In this case, since the WordPress installation is in your subfolder, the breadcrumb pathway seems to be working as expected that it is considering the subfolder (example.com/blog) as the ‘Home’ URL.
You’ll need for the WordPress installation to be on the root website for the breadcrumb pathway and structure to match what you require.
But the subfolder isn’t the home url. The homepage is the home url. So how can that be ‘as expected’..? It semantically makes no sense.
The rest of the site outside of WordPress has breadcrumbs that make sense and point to the real homepage etc as appropriate. The breadcrumbs for the subfolder (i.e. where WordPress is) should align with that, i.e.:-
Home (example.com) > Blog (example.com/blog/) > Category > Post NameHow do I get it to properly reflect the true structure of the site?
@smartyp The ‘Home’ URL in WordPress is relative to the root folder in which WordPress is installed in. So if it is in a subdirectory named ‘blog’ it would consider example.com/blog/ as the home URL.
We do also have a developer filter of wpseo_breadcrumb_links available that allows you to edit the breadcrumbs pathway programmatically. You can find more information on this in the article here, as well examples of how to use it here.
There is no ‘Home’ in WordPress – do you mean in Yoast? (Unless you’re referring to the historically poorly named ‘home_url’ function which returns the front end url of WordPress, not the home url of the site?)
Hi,
If you go to Settings-General what are the URLs that are appearing in the WordPress and Site Address fields?
If they are: example.com/blog/ then the breadcrumbs are working correctly. We take whatever URL is listed there and output it as the Home breadcrumb item.
If you want to change it to be something else you can! You would need to use that filter mentioned above to change it programmatically.
We take whatever URL is listed there and output it as the Home breadcrumb item.
Right, so it’s a bug then. That is, Yoast does not recognise when it’s being used in a subfolder so breadcrumbs don’t work correctly in this case. And there is no built-in option to cater for this either.
So you’re saying as a workaround to your bug it’s possible to use the wpseo_breadcrumb_links filter to get correct behaviour. OK. Can you provide an example of how to do that? I didn’t see anything in the examples linked above that was similar.
Hi, again, it’s relative to where the WordPress installation is, so since it is installed in a subfolder, it is treating it as the home URL. It’s not a bug, and the breadcrumbs are working as intended.
You can refer here for more information if you need to change the breadcrumb pathway – https://yoast.com/help/implement-wordpress-seo-breadcrumbs/#pathway
it is treating it as the home URL
Well exactly – it isn’t the home url but it’s treating it that way. Which makes no semantic sense.
It is a bug if it doesn’t behave in a logical expected way. Breadcrumbs are relative to the homepage, not to a subfolder. Breadcrumbs are not unique to Yoast, they are a website navigation feature – if they ignore the rest of a websites structure then they are broken.
So you guys don’t have a workaround for this bug then either?
Hi @smartyp,
Thankfully, Yoast SEO already offers two ways to achieve the breadcrumb path that you mentioned, so there doesn’t look like there’s a bug that needs to be fixed:
Solution #1: For complete control of the breadcrumb links, we recommend using the developer filter that my colleagues mentioned.
Solution #2: As an alternative, if you don’t want to add custom code, you can change the breadcrumb settings following the steps below:
1. Go to SEO > Search Appearance > Breadcrumbs.
2. Change the “Anchor text for the Homepage” to “Blog”.
3. For the “Prefix for the breadcrumb path” field, add the following text:
<a href="https://example.com/">Home</a> ?
. You can customize the link and separator to match your site.4. Click the “Save Changes” button.
As for a bug report, there are many other reasons why a WordPress site may be installed in a subdirectory, so it’s not clear that it would be safe to assume that every site needs the breadcrumb structure to change or to change in exactly the same way.
If you’d like to bring this to the attention of our developers as a new feature and explain the use case, you’re welcome to create a new feature request in our GitHub repository.
I appreciate the detailed steps, but unfortunately Solution #2 doesn’t really work because it doesn’t do anything to fix the schema, which is of course important.
Solution #1 might work – but it seems you don’t have a working example anywhere.
I don’t think there are ‘many other reasons’ for WP being in a subfolder though – I can think of only 1 other reason and that’s very rarely done compared to what’s discussed here. So whilst it may not be safe to assume every subfolder install is the same, it’s wrong for this setup.
But I’ve beaten my head against the wall enough so I’ll politely decline the invitation to create a ‘feature request’ ??
@smartyp Thanks for your reply.
In regards to WordPress being installed in a subfolder, there are many types of users who use WordPress exclusively for a blog and have their main site in the root of the domain.
In addition, some other users install the WordPress core files into a subdirectory but still have the site served from the main domain in the following fashion: https://deliciousbrains.com/how-why-install-wordpress-core-subdirectory/
Also, you can find the official documentation from WordPress on both methods here: https://www.ads-software.com/support/article/giving-wordpress-its-own-directory/
Regarding examples on how to implement the
wpseo_breadcrumb_links
developer filter, you can find example usage of the filter available here.Also, if you look around online you can also find other users and examples of how they used
wpseo_breadcrumb_links
to modify the breadcrumbs pathway such as in the following article: https://wordpress.stackexchange.com/questions/100012/how-to-add-a-page-to-the-yoast-breadcrumbsIn regards to WordPress being installed in a subfolder, there are many types of users who use WordPress exclusively for a blog and have their main site in the root of the domain.
Not a surprise to me given that’s the specific case we’ve been talking about here…
In addition, some other users install the WordPress core files into a subdirectory but still have the site served from the main domain
Yes, that’s the ‘other’ case I alluded to above…
So for all of that you’re just agreeing with me then? There aren’t “many other reasons” – there’s just 1 (…bangs head against wall again…).
Yup, same link again – not very helpful.
New link – partial solution on stackexchange..!
You’d think given “there are many types of users who use WordPress exclusively for a blog and have their main site in the root of the domain” that either Yoast would work for this use case, or you would have published a functioning workaround specifically for it.
Hi @smartyp,
Thanks for your patience. To prevent any further head injuries (hopefully!), what you’re asking for — plugin changes and specific code for your site — is a bit beyond the scope of support that we can offer on these forums, unfortunately.
We’re really sorry that there aren’t better options than what we’ve already offered at the moment, but it’s something that we can bring to the attention of the developers.
- The topic ‘Breadcrumbs not working correctly for subfolder install’ is closed to new replies.