Building a Guide Page
Introduction: The Purpose of a Guided Cooking Page
Welcome to the first lesson of this course! In this lesson, you will learn how to create a step-by-step cooking guide page for a recipe. This type of page is a key feature in many cooking helper apps. It helps users follow a recipe one step at a time, making the cooking process easier and less overwhelming.
Imagine you are cooking a new dish. Instead of scrolling through a long list of instructions, you see only the current step, with clear navigation to move forward or backward. You might also have a timer for certain steps and even a button to read the instructions out loud. This is the experience we want to create.
By the end of this lesson, you will understand how to build the basic structure of this guide page using HTML and Flask templates. This will lay the foundation for adding more interactive features in future lessons.
Recall: HTML Templates and Inheritance
Before we dive in, let’s quickly recall how HTML templates work in Flask. If you remember from your previous experience (or if this is new, don’t worry), Flask uses a system called template inheritance. This means you can create a base layout (like a skeleton) and then build specific pages on top of it.
For example, you might have a layout.html file that looks like this:
{% block ... %}is a placeholder that child templates can fill in.{% extends "layout.html" %}in a child template means "use the layout fromlayout.htmland fill in the blocks."
This approach keeps your code organized and avoids repeating the same HTML structure on every page.
Building the Guide Page Structure
Let’s start building the step-by-step guide page. We’ll do this by creating a new template that extends the base layout and adds the sections we need.
1. Extending the Base Layout
First, we tell Flask to use our base layout:
This line means our new page will use the structure from layout.html.
