cisagov / get.gov

The website for the .gov registry
https://get.gov
Other
15 stars 2 forks source link

Implement search.gov for {beta.}get.gov #126

Closed calerubensteingsa closed 8 months ago

calerubensteingsa commented 1 year ago

Updated 5/16

AC:

Search.gov documentation on setting up search on cloud.gov page. Note that some of the details on that documentation page are specific to Jekyll sites.

Dependent on cisagov/manage.get.gov#618 and cisagov/manage.get.gov#620

igorkorenfeld commented 1 year ago

Search has been setup on get.gov but the cloud.gov pages preview currently cannot be indexed by serach.gov. However, we will be able to get it indexed if and when the preview site moves to a "beta" or "demo" subdomain.

When setting up the subdomain it will be important to avoid linking to the beta site in other sites, since those may be crawled by commercial search engines. We want to limit the new site's discoverability during the beta phase since the new process will not be in place and we don't want visitors to be confused. Additionally we will need to include a robots.txt file that will disallow search engines from crawling the site. Search.gov has helpful documentation on this. Once the robots.txt configuration is set up we can request Serach.gov to index the site, after which we can test to make sure the search and results are working as expected.

These notes capture the relevant details from our slack conversation from 3/31/23

gabydisarli commented 1 year ago

Marking this as a 'Yes' for MVP but @h-m-f-t notes in our insight repository that he could see this falling to a no.

michelle-rago commented 10 months ago

@erinysong @CocoByte Here are the (I think) relevant files for search.gov implementation. I was working on this in a search-options branch.

https://github.com/cisagov/getgov-home/blob/search-options/_data/site.yaml https://github.com/cisagov/getgov-home/blob/search-options/pages/search.html https://github.com/cisagov/getgov-home/blob/search-options/_includes/searchgov/form.html

Search.html includes, but "No results found" isn't appearing.

   }).finally(function(e){
      document.getElementById('search-field-en-big').value = params.query;
      if(document.getElementById('search-results').childNodes.length == 0){
        render_result(`<h4 class="title">No results found</h4>`, true)
      }

Another developer said:

finally
if(document.getElementById('search-results').childNodes.length == 0)

is false even with no results, the count is 1 on the example page you sent. The element in the NodeList that results in a length of 1 is a text element whose content is \n (newline). I’m thinking perhaps if the newline is removed from the template that would cause the count to be 0 as expected.

erinysong commented 10 months ago

I'd may have a better idea of how the newline text element should be handled if I look more closely at your code, but the first thing that comes to mind as a quick fix is also checking if the childNodes contains 1 newline element (under the condition this only happens when our search results are empty) and displaying the No results found message under that condition. Happy to talk over this on a call too!