Section 7.2 Search
Search facilities are enabled through
Google Custom Search Engine. Please, please report any discrepancies in the following instructions as the setup interface at Google changes out from underneath us. These instructions are accurate as of 2016-12-12.
Besides being useful for search facilities, setting up a search engine might be a good way to alert Google of something newly available, and initiate your book's rise up the search results rankings.
Create an account with Google (GMail, YouTube, etc.) and make sure you are signed in.
Add a new search engine of follow
New Search Engine.
URL for the top-level domain name/directory for your book/document. Everything below this will be indexed. We have taken some care to mark knowl content in a way compatible with the search facility, but there is more work to do here.
Give the engine a GCSE-specific name, so you can tell later which one it is when you have several.
Edit Search Engine > Setup > Basics > Details > Search engine ID find a string which uniquely identifies your new search engine. Save this, you'll need to make it part of your
Edit Search Engine > Setup > Admin add co-authors or trusted backup personnel.
Edit Search Engine > Business > Settings set your
Advertising status to the non-profit setting if you qualify (most universties should).
Edit Search Engine > Look and Feel at your own risk! Only the defaults are tested and supported.
Edit Search Engine > Setup > Indexing sends you to Google Search Console to see if your book is already being indexed. YOu may need to go through a confirmation process to establish that you are the owner of the website being indexed. If you see taht your book is not yet being indexed, you may want to wait as long as a week before your material does get indexed and you make a search box available.
List 7.2.1 Configuring Google Custom Search
Search engine ID you saved from above is referenced in Google's code as a
cx number. Add an element in your MBX source as
docinfo/search/google/cx with the value of your book's ID as the content. See the sample article for a working example to mimic.
cx element will alert the PreTeXt conversion and fully enable and implement search. You're done, and everything should just work. You should see a Google-branded search box to the top right of each of your pages. (We have no control over the branding.)
Time to rebuild your official
HTML output and make the improved version available. List 7.2.2 Configuring PreTeXt for Google Search