How to Open Google Custom Search Links in the Same Window (2026)
Do you use Google Custom Search for your site search? Google’s free Programmable Search Engine (still widely called Google Custom Search) powers the search box on thousands of websites. But by default it opens every result in a new browser tab, which can annoy visitors and leave them with a pile of tabs. Here is how to make Google Custom Search open result links in the same window in 2026.

Quick answer: Add data-linkTarget="_self" to the search results element in your Programmable Search Engine code, for example <div class="gcse-searchresults-only" data-linkTarget="_self"></div>. Google’s default link target is _blank, which opens a new tab.
Table of Contents
Why open search results in the same window?
- It matches how normal Google search and most site searches behave.
- Visitors can use the Back button to return to the results.
- Fewer stray tabs, especially on phones, where new tabs are confusing.
Some site owners prefer new tabs so the results page stays open. Either is fine; pick what suits your readers.
How to change the link target in Programmable Search Engine
- Sign in to the Programmable Search Engine control panel and open your search engine.
- Copy your search engine code. It includes a script tag with your engine ID (cx) and a div for the search box and results.
- Add the
data-linkTargetattribute to the results element:
<script async src="https://cse.google.com/cse.js?cx=YOUR_ENGINE_ID"></script>
<div class="gcse-search" data-linkTarget="_self"></div>If you use a separate results page, add it to the results div instead:
<div class="gcse-searchresults-only" data-linkTarget="_self"></div>The attribute works on the searchresults and searchresults-only components, as listed in Google’s Programmable Search Element documentation.
Old versions of the code
Older Custom Search code used tags like <gcse:searchresults linktarget="_parent"> or a JavaScript option called setLinkTarget. If your site still has the old version 1 code, replace it with the current snippet from the control panel, then add the attribute above.
Tips for a better site search
- Use a results page layout (“two page”) so results show on a dedicated page in your theme.
- Restrict to your own site so visitors only see your pages.
- Add refinements to filter results by section, such as Tutorials or Reviews.
- Check what people search for in the control panel statistics, and write posts that answer popular searches.
- Clean up weak pages that show up in results; see how to find thin content.
You can also let visitors search your site straight from the Chrome address bar. Here is how to add site search to Chrome.
FAQ
Is Google Custom Search still free?
Yes. The standard Programmable Search Engine is free with ads in the results. Ad-free options are available for some organisations.
Why do my search results still open in a new tab?
Clear your cache, check the attribute is on the results element (not only the search box), and make sure a theme or plugin is not adding target=”_blank”.
Can I use the WordPress search instead?
Yes. WordPress search is built in, but Google’s search is often better at ranking relevant results on large sites.
Do you prefer search results in the same tab or a new tab? Tell us in the comments.
Get our free weekly email: new tech guides and tools, no spam.
New and updated tech guides, a free tool worth bookmarking and one useful pick, once a week. No spam, unsubscribe anytime.
One email a week. Unsubscribe anytime. See our privacy policy.







I have used the linktarget=”_parent” on the search results page and it works a charm. I also had a look at the Google Custom search API and it only says what the default is. This helped. Thanks.
Great simple solution to a pretty irritating problem. Thanks for sharing!
Its a great tip and I am glad it helps.
Had this question today and figured out how to do it using the new code:
Google’s Documentation has all the options you can use:
https://developers.google.com/custom-search/docs/element
It’s s good idea — and something I’ve been looking to do, but we’re not using the Version 1 code (and there are many reasons it’s not a good idea to use the old code). Would love to know how to open the search results in the same window in Version 2. By the way, QOT is my new favorite blog – thanks.
In version 2, add linktarget=”_parent” in the gcse:searchresults-only line on the results page.
Example: