{"id":29791,"date":"2012-09-16T22:11:16","date_gmt":"2012-09-16T16:41:16","guid":{"rendered":"https:\/\/www.quickonlinetips.com\/archives\/?p=29791"},"modified":"2026-10-11T17:29:11","modified_gmt":"2026-10-11T11:59:11","slug":"google-custom-search-results-links-same-window","status":"publish","type":"post","link":"https:\/\/www.quickonlinetips.com\/archives\/2012\/09\/google-custom-search-results-links-same-window\/","title":{"rendered":"How to Open Google Custom Search Links in the Same Window (2026)"},"content":{"rendered":"<p>Do you use Google Custom Search for your site search? Google&#8217;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 <strong>Google Custom Search<\/strong> open result links in the same window in 2026.<\/p>\n<p><img decoding=\"async\" class=\"aligncenter size-large wp-image-64015\" src=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/google-custom-search-same-window-1024x538.webp\" alt=\"Open Google Custom Search links in same window\" width=\"1024\" height=\"538\" srcset=\"https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/google-custom-search-same-window-1024x538.webp 1024w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/google-custom-search-same-window-300x158.webp 300w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/google-custom-search-same-window-150x79.webp 150w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/google-custom-search-same-window-768x403.webp 768w, https:\/\/www.quickonlinetips.com\/archives\/wp-content\/uploads\/google-custom-search-same-window.webp 1200w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/p>\n<p><strong>Quick answer:<\/strong> Add <code>data-linkTarget=\"_self\"<\/code> to the search results element in your Programmable Search Engine code, for example <code>&lt;div class=\"gcse-searchresults-only\" data-linkTarget=\"_self\"&gt;&lt;\/div&gt;<\/code>. Google&#8217;s default link target is <code>_blank<\/code>, which opens a new tab.<\/p>\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_89 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6ad79cd0a7bc7\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"ez-toc-cssicon\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #1a202c;color:#1a202c\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #1a202c;color:#1a202c\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6ad79cd0a7bc7\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/09\/google-custom-search-results-links-same-window\/#Why_open_search_results_in_the_same_window\" >Why open search results in the same window?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/09\/google-custom-search-results-links-same-window\/#How_to_change_the_link_target_in_Programmable_Search_Engine\" >How to change the link target in Programmable Search Engine<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/09\/google-custom-search-results-links-same-window\/#Old_versions_of_the_code\" >Old versions of the code<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/09\/google-custom-search-results-links-same-window\/#Tips_for_a_better_site_search\" >Tips for a better site search<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/09\/google-custom-search-results-links-same-window\/#FAQ\" >FAQ<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/09\/google-custom-search-results-links-same-window\/#Is_Google_Custom_Search_still_free\" >Is Google Custom Search still free?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/09\/google-custom-search-results-links-same-window\/#Why_do_my_search_results_still_open_in_a_new_tab\" >Why do my search results still open in a new tab?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/09\/google-custom-search-results-links-same-window\/#Can_I_use_the_WordPress_search_instead\" >Can I use the WordPress search instead?<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<h2><span class=\"ez-toc-section\" id=\"Why_open_search_results_in_the_same_window\"><\/span>Why open search results in the same window?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li>It matches how normal Google search and most site searches behave.<\/li>\n<li>Visitors can use the Back button to return to the results.<\/li>\n<li>Fewer stray tabs, especially on phones, where new tabs are confusing.<\/li>\n<\/ul>\n<p>Some site owners prefer new tabs so the results page stays open. Either is fine; pick what suits your readers.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"How_to_change_the_link_target_in_Programmable_Search_Engine\"><\/span>How to change the link target in Programmable Search Engine<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ol>\n<li>Sign in to the <a href=\"https:\/\/programmablesearchengine.google.com\/\" target=\"_blank\" rel=\"noopener\">Programmable Search Engine control panel<\/a> and open your search engine.<\/li>\n<li>Copy your search engine code. It includes a script tag with your engine ID (cx) and a div for the search box and results.<\/li>\n<li>Add the <code>data-linkTarget<\/code> attribute to the results element:<\/li>\n<\/ol>\n<pre><code>&lt;script async src=\"https:\/\/cse.google.com\/cse.js?cx=YOUR_ENGINE_ID\"&gt;&lt;\/script&gt;\n&lt;div class=\"gcse-search\" data-linkTarget=\"_self\"&gt;&lt;\/div&gt;<\/code><\/pre>\n<p>If you use a separate results page, add it to the results div instead:<\/p>\n<pre><code>&lt;div class=\"gcse-searchresults-only\" data-linkTarget=\"_self\"&gt;&lt;\/div&gt;<\/code><\/pre>\n<p>The attribute works on the searchresults and searchresults-only components, as listed in Google&#8217;s <a href=\"https:\/\/developers.google.com\/custom-search\/docs\/element\" target=\"_blank\" rel=\"noopener\">Programmable Search Element documentation<\/a>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Old_versions_of_the_code\"><\/span>Old versions of the code<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Older Custom Search code used tags like <code>&lt;gcse:searchresults linktarget=\"_parent\"&gt;<\/code> or a JavaScript option called <code>setLinkTarget<\/code>. 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.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"Tips_for_a_better_site_search\"><\/span>Tips for a better site search<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<ul>\n<li><strong>Use a results page layout<\/strong> (&#8220;two page&#8221;) so results show on a dedicated page in your theme.<\/li>\n<li><strong>Restrict to your own site<\/strong> so visitors only see your pages.<\/li>\n<li><strong>Add refinements<\/strong> to filter results by section, such as Tutorials or Reviews.<\/li>\n<li><strong>Check what people search for<\/strong> in the control panel statistics, and write posts that answer popular searches.<\/li>\n<li><strong>Clean up weak pages<\/strong> that show up in results; see how to <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/02\/find-thin-content\/\">find thin content<\/a>.<\/li>\n<\/ul>\n<p>You can also let visitors search your site straight from the Chrome address bar. Here is how to <a href=\"https:\/\/www.quickonlinetips.com\/archives\/2012\/05\/site-search-google-chrome-search-engine\/\">add site search to Chrome<\/a>.<\/p>\n<h2><span class=\"ez-toc-section\" id=\"FAQ\"><\/span>FAQ<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><span class=\"ez-toc-section\" id=\"Is_Google_Custom_Search_still_free\"><\/span>Is Google Custom Search still free?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Yes. The standard Programmable Search Engine is free with ads in the results. Ad-free options are available for some organisations.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Why_do_my_search_results_still_open_in_a_new_tab\"><\/span>Why do my search results still open in a new tab?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>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=&#8221;_blank&#8221;.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"Can_I_use_the_WordPress_search_instead\"><\/span>Can I use the WordPress search instead?<span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>Yes. WordPress search is built in, but Google&#8217;s search is often better at ranking relevant results on large sites.<\/p>\n<p>Do you prefer search results in the same tab or a new tab? Tell us in the comments.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Do you use Google Custom Search for your site search? Google&#8217;s free Programmable Search Engine (still widely called Google Custom&#8230;<\/p>\n","protected":false},"author":4,"featured_media":64015,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6,3],"tags":[49],"class_list":["post-29791","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blogging","category-google","tag-tutorials"],"_links":{"self":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/29791","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/comments?post=29791"}],"version-history":[{"count":2,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/29791\/revisions"}],"predecessor-version":[{"id":64017,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/posts\/29791\/revisions\/64017"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media\/64015"}],"wp:attachment":[{"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/media?parent=29791"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/categories?post=29791"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.quickonlinetips.com\/archives\/wp-json\/wp\/v2\/tags?post=29791"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}