Add a custom search engine to your blog

Source: Internet
Author: User
Cnblog.org has added a search function in the upper right corner of the experience set. Enter a keyword and then enter the search function of Google. The difference is that there is a custom cnblog.org logo on the interface, and you can choose whether to search within the site or on the network. Because cnblog.org's new site is not long enough, the content currently searched is still limited, which is determined by Google's search algorithm.

If you are interested in adding such a custom search engine to your blog. Don't worry. First go to Google to search and see if your page has been indexed by Google. If you find more than one hit, you can follow the steps below to apply for a free customized Google site search:

1First go to Google search solutions and use your email to register a free sitesearch account.
2. Then enter your blog address according to the instructions. If you are on blogspot.com, enter the complete xxx.blogspot.com (if Google does not have your page index, Google will not agree with your application, please wait several days)
3You can enter custom information, such as the icons of your site, and other color information and layout formats. There are not many customized content, so you can just take the customer with you.
4. Google then provides you with some code that allows you to insert to a proper position on the page. However, this code shows a lot of content, which may not be consistent with your page style. We have simplified the code, only one input box and one search button are displayed. The Google icon and intra-Site Search/online search options are ignored. The Google icon is displayed on the search page, so it does not violate the spirit of Google's protocol.

The simplified code is as follows: (here is just an example. You need to change the address section to your site features. We will mark it in yellow)
<! -- Search Google -->
<Form method = get action = http://www.google.com/custom>
<Input type = text name = Q size = 20 maxlength = 255 value = "">
<Input type = submit name = sa value = "Search">
<Input type = hidden name = COF value = "L: http://www.cnblog.org/images/cnblog_logo.gif#ah:left;
S: http://www.cnblog.org; awfid: f26bf4ce556af46f; ">
<Input type = hidden name = domains value = "cnblog.org">
<Input type = hidden name = sitesearch value = "cnblog.org">
</Form>
<! -- Search Google -->

I believe that as your site is accessed more frequently, the search accuracy and hit rate will become higher and higher.

1. First, go to Google to apply for a free intra-site search engine. Complete the following steps.

2. Get the HTML search code from Google, such
<! -- Search Google -->
<Center>
<Form method = get action = http://www.google.com/custom>
<Table bgcolor = # ffffff cellspacing = 0 border = 0>
<Tr valign = top> <TD>
<A href = http://www.google.com/search>
& Lt; IMG src = http://www.google.com/logos/Logo_40wht.gif border = 0 alt = Google align = Middle & gt; & lt;/A & gt;
</TD>
<TD>
<Input type = text name = Q size = 31 maxlength = 255 value = "">
<Input type = submit name = sa value = "Google Search">
<Input type = hidden name = COF value = "Ah: center; awfid: 3182aae82da4ddf8;">
<Input type = hidden name = domains value = "blog.csdn.net"> <br> <input type = radio name = sitesearch value = ""> % (domain) S <input type = radio name = sitesearch value = "blog.csdn.net" Checked> % (domain) S
</TD> </tr> </table>
</Form>
</Center>
<! -- Search Google -->

 

3. encoding problem. If it is gb2312 encoding, add the following to the form:
<Input type = hidden name = ie value = "gb2312">
<Input type = hidden name = OE value = "gb2312">
Chedong supplemented this and can be seen here

4. Choose> static news/declaration in the configuration on the blog management interface and add the above search engine form code.
Trying. :). This blog system is Asp.net, and the entire page is a web form ,. net web form has a very large form when it is created. Look at the HTML source code and you will find a form named form1 behind the body, there is also a form in the code that Google gives you. form cannot be nested.

5. modify the code that Google gave you and remove the form tag (do not forget to remove the end tag </form> ), add the following script to static news/Declaration (before Google Code)
<Script language = "JavaScript">
Function on_search_click (){
Form1.action = "http://www.google.com/custom ";
Form1.target = "_ blank ";
Form1.method = "get ";
}
</SCRIPT>
Then add the onclick event: onclick = "javascript: on_search_click ()" to the submit button (that is, the Google search button ()".
Okay. When you click query, the submission direction of the form1 form changes.

6. Modify the interface appearance of the query block.
Because the code that Google gives you may not be integrated into your page style, or even break down your leftmenu because the text input box is too long. You need to make some modifications to the code. Remove unnecessary images and change the length of the text box. In addition to those form objects, elements such as input and button cannot be removed, other Google Images and tables can be removed. You can also modify the style of form objects.

Now, you can use the search engine on the blog site. :)

My modifications are as follows:

<Script language = "JavaScript">
Function on_search_click (){
Form1.action = "http://www.google.com/custom ";
Form1.target = "_ blank ";
Form1.method = "get ";
}
</SCRIPT>
<! -- Search Google -->
<Center>
<Table cellspacing = "0" border = "0">
<Tr> <TD> Google query: </TD> </tr>
<Tr valign = "TOP"> <TD>
<Input type = "text" name = "Q" maxlength = "255" value = "" style = "width: 130px; Border: 3px double # cecece;">
<Input type = "Submit" name = "sa" value = "Search" onclick = "javascript: on_search_click ()">
<Input type = "hidden" name = "COF" value = "Ah: center; awfid: 3182aae82da4ddf8;">
<Input type = "hidden" name = "ie" value = "gb2312">
<Input type = "hidden" name = "oe" value = "gb2312">
<Input type = "hidden" name = "domains" value = "blog.csdn.net"> <br>
<Input type = "radio" name = "sitesearch" value = "> by WWW
<Input type = "radio" name = "sitesearch" value = "blog.csdn.net" Checked = "checked"> by me
</TD> </tr> </table>
</Center>
<! -- Search Google -->
<Br>


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.