Control indexing of listing search results
- Thread started
- Last updated
What you’ll achieve
Control which search and filtered listing pages search engines can index.
My site
Check the robots tags on filtered listing results and keep the pages you choose out of search-engine results. A robots tag is an instruction in the page source. noindex asks search engines to leave that page out of search results; follow allows them to follow its links, while nofollow asks them not to. These settings do not stop visitors from opening the page.
Check filtered and unfiltered listing URLs
Compare a filtered listing result, an unfiltered category, an ordinary later results page, and a listing detail page. On each page, right-click and choose View page source. Search for name="robots" and record its content value. Search for rel="canonical" and record the URL in href. A canonical tells search engines which URL you prefer for duplicate or very similar pages. A query parameter alone is not proof that a page is filtered; custom-field filter URLs can use only jr_* parameters.
JReviews 6
Inspect the built-in robots output
JReviews 6 applies its built-in robots policy to filtered listing results. Filters that change which listings appear can receive noindex, follow. Pagination, sort order, and layout settings are treated separately.
Check the built-in output before adding custom robots code. Inspect the final output because overrides and SEO extensions can change it.
JReviews 5
Add a rule for search and selected field filters
Joomla. Add the callback to templates/jreviews_overrides/filters/filter_functions.php.
WordPress. Add the callback to jreviews_overrides/filters/filter_functions.php.
Start a new file with <?php followed by defined('MVC_FRAMEWORK') or die;. Add the callback to an existing file without repeating those lines.
Clickfwd\Hook\Filter::add('page_robots_metatag', function ($robots, $params) {
if (!str_starts_with((string) ($params['route'] ?? ''), 'categories.')) {
return $robots;
}
$filterNames = ['query', 'jr_color'];
$filtered = false;
foreach ($filterNames as $name) {
$values = (array) ($_GET[$name] ?? []);
foreach ($values as $value) {
if (is_scalar($value) && trim((string) $value) !== '') {
$filtered = true;
break 2;
}
}
}
if ($filtered) {
return stripos((string) $robots, 'nofollow') !== false
? 'noindex, nofollow'
: 'noindex, follow';
}
return $robots;
}, 20);
The filter changes JReviews' robots value before the CMS writes the page's metadata. It preserves an existing nofollow instruction and does not add a second robots tag.
Set $filterNames to the actual filter parameters used on your site. This example covers an advanced-search URL with query=all and the original color-filter case, ?jr_color=red. Add fields such as jr_state only when those parameters narrow your listing results.
The route check limits the callback to JReviews listing lists. The list of filter names leaves an ordinary ?pg=2, sort option, or tracking parameter alone. Pagination of an already filtered list still receives noindex. The callback does not change a listing detail page or media page.
Keep a nonempty unfiltered category available for the indexable comparison. JReviews may already exclude an empty list for its own reasons.
Confirm both excluded and indexable pages
Repeat the page-source checks for each URL from Check filtered and unfiltered listing URLs. Also open the browser's developer tools, select Network, and reload the page. Select the main page request, open Headers, and look under Response Headers for X-Robots-Tag. It can contain search-engine instructions outside the HTML; record its value if present. Confirm that the filtered page has the intended noindex instruction. Check that categories, listing detail pages, and normal results pages retain the robots settings you chose. If tags conflict, change the extension or template that generates them.
See Plan directory crawling, indexing, and canonicals for the surrounding URL decisions. Search engines must be allowed to visit the page to read its noindex tag. Do not block that visit with a rule in your site's robots.txt file.
Learn more
- SEO (v5)
- Hooks (v5)
- SEO (v6)
- Hooks (v6)
- Early Access (v6)