This page is also available in English.View in English

← Quay lại blog

Claude Code Tutorial: Fix a Broken Link

Use two short HTML pages to practice Claude Code: find a broken link, change one line, inspect the diff, test the link and undo the change.

4 phút đọc

This exercise fixes one problem: the About me link on a homepage won't open the next page. You'll ask Claude Code to find the cause, change one thing, then check the page yourself. You need just two HTML files, with no server or Git repository.

You can copy the task messages below into Claude Code. Its replies may vary; judge the result by the saved files and what happens when you click.

1. Make two pages and try the broken link

Create an empty folder called starter. Use a plain-text or code editor to save these two files. Make sure their names don't end in an extra .txt.

index.html is the homepage:

html

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>My portfolio</title> </head> <body> <h1>My portfolio</h1> <p>This is a practice website.</p> <a href="about-me.html">About me</a> </body> </html>

about.html is the second page:

html

<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>About me</title> </head> <body> <h1>About me</h1> <p>This page is part of a coding exercise.</p> <a href="index.html">Back to home</a> </body> </html>

Double-click index.html and click About me in your browser. The link points to about-me.html, but the folder contains about.html, so it won't open. The error message depends on your browser.

The minimal exercise homepage before its About me link is fixed
Exercise homepage: the link says about-me.html, but the file is named about.html.

Before editing, copy index.html and name the copy index.before.html. Keep it in the same folder for comparing and undoing the change.

2. Install Claude Code and open this folder

You'll need an account with Claude Code access. If it's already installed, go straight to the version check. Otherwise, follow Anthropic's official quickstart and run the command for your system in a terminal.

macOS, Linux or WSL:

bash

curl -fsSL https://claude.ai/install.sh | bash

Windows PowerShell:

powershell

irm https://claude.ai/install.ps1 | iex

Run that Windows command in PowerShell. After installation, open a new terminal and check:

bash

claude --version

Continue when you see a version number. If the command isn't found, follow the quickstart's troubleshooting instructions first.

Run the following commands on separate lines. Replace the example path with the full path to your starter folder, keeping the double quotation marks:

bash

cd "/path/to/starter" claude

Follow the sign-in prompts on first launch. If the browser doesn't open, follow the terminal's instructions to copy the login link; see the official sign-in guide. Check that the session shows your starter folder as its working directory.

3. Find the cause before changing anything

Send this to Claude Code:

Read-only check

Inspect only index.html and about.html in the current folder. Do not edit files. Clicking About me on the homepage doesn't open the second page. Find the link address, the actual filename, and the mismatch. index.before.html is a backup. Do not change it. Tell me the one change needed, but do not make it yet.

Look for an answer that identifies about-me.html versus about.html and proposes changing only the homepage link's href. That attribute is the address a link opens.

If it proposes creating another page or rewriting the site, explain that the target page already exists: only the address needs fixing. Investigating before choosing a fix also follows Anthropic's debugging workflow.

4. Change the link and inspect the diff

Once you've checked the cause, send:

Change one link

In index.html, change only the About me link from about-me.html to about.html. Do not change other text, about.html or index.before.html. Save the file, compare index.before.html with index.html, show the diff and list the files changed. Do not publish the website.

A diff shows what changed between two versions. This one should contain a single changed line:

diff

- <a href="about-me.html">About me</a> + <a href="about.html">About me</a>

The - marks the old line and + the new one; don't put those markers into your HTML. An actual diff may also show line numbers and unchanged surrounding code.

If a permission prompt appears, check which file it intends to change. Whether you see a prompt depends on your permission settings, so a missing prompt doesn't mean nothing changed. Open index.html in your editor too: confirm that it contains the new address and the backup still has the old one.

5. Click through it yourself

Refresh the homepage and click About me again. Check three things:

  • The address bar points to local about.html, and the page says About me.
  • Back to home takes you to index.html.
  • The file difference contains only the homepage link address; the second page and backup haven't changed.
The About me page opened correctly in the minimal exercise
Check the result: clicking the homepage link opens the existing about.html file.

If it still fails, check whether you opened another copy, saved a filename with .txt, or put the pages in different folders. Claude Code saying it's fixed isn't a substitute for this click.

6. Undo the change once

Open index.before.html in your editor. Copy all its contents back into index.html and save. Refresh the homepage and click About me: the broken link should return. That confirms you restored the original file.

To keep the fix, change that one address back to about.html and click through again. You should now be able to explain the cause, identify the changed line and undo it.

Finish this exercise locally. When a real project needs a second assistant to review the work, see Pachat's Claude Code collaboration guide.

References

  1. Claude Code quickstart, Anthropic.
  2. Authentication, Anthropic.
  3. Permission settings, Anthropic.
  4. Common workflows, Anthropic.
  5. Claude Code with other assistants, Pachat.
Chia sẻXLinkedInFacebookRedditWhatsAppEmail

Bài viết khác trên blog

Tất cả bài viết →

Hãy bắt đầu từ quyết định bạn đang cân nhắc.