Home Page

Definition

A home page is the first page you see when you visit a website. It is usually used to tell visitors what they can find on the site. It serves as the main entry point and often provides navigation to other parts of the website.

Example: Creating a Home Page

In the context of building a web application, creating a home page involves setting up the initial HTML structure that users will interact with when they first visit the site. Below is an example of a simple home page for a fictional coffee shop, "E&E Coffee Shop."

[Listing 15.1: templates/index.html](https://livebook.manning.com/book/a-pythonic-adventure/chapter-15/1)

This listing demonstrates how to create a basic home page using HTML and a templating language. The page extends a base template and includes a welcome message, a form for placing new orders, and an image.

{% extends "base.html" %}
{% block content %}
 
<h1>Welcome to E&E Coffee Shop</h1>
 
<form action="/order">
<input type="submit" value="New order" />
</form>
 
<img src="/static/img/8507631_3925457.jpg"
 alt="Coffee drinks" width="100%">
Image by <a href="https://www.freepik.com/free-vector/
take-away-coffee-coffee-mugs_8507631.htm">Freepik</a>
 
{% endblock %}

Explanation

  • Template Extension: The home page extends a base template (base.html), which likely contains common elements like the header and footer.
  • Content Block: The main content of the home page is defined within a block named content.
  • Welcome Message: A simple <h1> tag is used to display a welcome message to visitors.
  • Order Form: A form is included with a single button that allows users to start a new order. The form action points to the /order endpoint.
  • Image: An image of coffee drinks is displayed, with attribution to the source provided via a link to Freepik.

This example illustrates the basic components of a home page, providing a welcoming interface and a clear call to action for users.

FAQ (Frequently asked questions)