Serving a fully functioning frontend to users

Of course, our little project can't really be complete without a proper frontend for our users! To build one, we will leverage the Go standard library's support for HTML templates (the text/template and html/template packages) to design a fully functioning static website for Links 'R' Us. For simplicity, all the HTML templates will be embedded into our application as strings and parsed into text.Template when the application starts. In terms of functionality, our frontend must implement a number of features.

First, it must implement an index/landing page where the user can enter a search query. Queries can either be keyword- or phrase-based. The index page should also include a link that can navigate users to another page where they can submit a website for indexing. The following screenshot shows a rendering of the index page template:

Figure 3: The landing page for Links 'R' Us

Next, we need a page where webmasters can manually submit their websites for indexing. As we mentioned previously, the index/landing page will include a link to the site submission page. The following screenshot shows what the rendered site submission page for indexing will look like:

Figure 4: A form for manually submitting sites for indexing

The final, and obviously most important, page in our entire application is the search results page. As shown in the following screenshot, the results page renders a paginated list of websites matching the user's search query. The header of the page includes a search text box that displays the currently searched term and allows users to change their search terms without leaving the page:

Figure 5: The paginated list of search results

The template for rendering the individual search result blocks, as portrayed in the preceding screenshot, consists of three sections:

Now that we have defined all the necessary templates for rendering the pages that compose the Links 'R' Us frontend, we need to register a series of HTTP routes to allow our end users to access our service.