How to Code Your Own Website: Build a Small Two-Page Site
To code your own website, create HTML files for the content, use CSS for presentation, test the files together, and publish them with hosting that fits how to optimize content for seo the project. Add JavaScript when a specific interaction needs it. A small informational website can work without a framework, database, or build tool.
This tutorial builds a two-page portfolio with a shared stylesheet. It is a learning project, not a complete booking system or online shop. You will have a home page, a work page, and navigation between them. The useful milestone is a site you can explain and maintain, rather than a collection of code you cannot change safely.
Start with two pages and one shared stylesheet
Create a project folder containing index.html, work.html, and styles.css. Keep all three files at the same level for this exercise. Save them as plain text with those exact extensions; a file named index.html.txt is not the intended HTML document.
MDN's file organization guide explains why names and paths matter, including differences in case sensitivity. A reference what is seo tools to Work.html may fail on a host when the actual file is work.html, even if a local environment did not reveal the mistake.
Write a short content plan before coding. In this fictional portfolio, the home page introduces a maker and the work page describes a sample project. Use clearly marked example content while learning. Replace it with accurate, approved information before publishing a real person's work or business claims.
Next action: Sketch the page structure so each page has a clear purpose before you spend time styling it.
1. Write the home page in HTML
HTML describes the content and its structure. MDN's first website module introduces the roles of HTML, CSS, and JavaScript. Treat do you need digital marketing or seo service those roles separately while learning: meaning and content come first, appearance follows, and scripting supplies behavior when needed.
Save the following original example as index.html. The navigation uses links rather than buttons because it moves readers to another page. The heading identifies this page's main topic, while the title gives the browser a page-specific name.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Home | Sample Maker</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<a class="skip" href="#main">Skip to content</a>
<header>
<p>Sample Maker — learning project</p>
<nav aria-label="Main">
<a href="index.html" aria-current="page">Home</a>
<a href="work.html">Work</a>
</nav>
</header>
<main id="main">
<h1>Useful objects, thoughtfully explained</h1>
<p>This fictional portfolio demonstrates a small website.</p>
<p><a href="work.html">Read the sample project</a></p>
</main>
<footer><p>Example content for learning.</p></footer>
</body>
</html>
The skip link is included to provide a route to the main content. Its presence alone does not certify accessibility. You still need to check keyboard behavior, focus visibility, reading order, text clarity, and the finished design in a browser.
2. Add a second page with matching navigation
Save this as work.html. The page keeps the same navigation labels and stylesheet reference, but changes the title, main heading, What is SEO software? and current-page marker. Shared conventions help visitors understand where they are without making every page's content identical.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Work | Sample Maker</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<a class="skip" href="#main">Skip to content</a>
<header>
<p>Sample Maker — learning project</p>
<nav aria-label="Main">
<a href="index.html">Home</a>
<a href="work.html" aria-current="page">Work</a>
</nav>
</header>
<main id="main">
<h1>A sample desk organizer project</h1>
<p>This invented project shows where a real case study could go.</p>
<h2>What the page should explain</h2>
<p>Describe the problem, the work, and the evidence honestly.</p>
</main>
<footer><p>Example content for learning.</p></footer>
</body>
</html>
These links are relative to the current folder. Avoid replacing them with a path from your own computer. A visitor cannot access your local drive, and an operating-system file path is not a public website URL. Keep the folder structure consistent when you upload the project.
3. Give both pages a shared design
Save the CSS below as styles.css. Both HTML documents reference it, so one style change can affect both pages. The layout uses a readable maximum width and flexible navigation rather than a fixed desktop canvas.
* { box-sizing: border-box; }
body {
margin: 0;
font-family: system-ui, sans-serif;
font-size: 1.125rem;
line-height: 1.6;
color: #172b3a;
background: #ffffff;
}
header, main, footer {
width: min(100% - 2rem, 48rem);
margin-inline: auto;
padding-block: 1rem;
}
nav { display: flex; flex-wrap: wrap; gap: 1rem; }
a { color: #064c85; text-underline-offset: 0.2em; }
a:focus-visible { outline: 3px solid #172b3a; outline-offset: 4px; }
[aria-current="page"] { font-weight: 700; }
h1 { line-height: 1.2; overflow-wrap: anywhere; }
.skip { display: inline-block; margin: 0.5rem 1rem; }
If neither page appears styled, check the filename, the stylesheet link, and whether the CSS file was saved. If only one page looks what is sandbox in seo wrong, compare that page's link and markup first. Changing several unrelated things at once makes it harder to identify the cause.
For layout planning beyond this example, see how to design a website. A more elaborate appearance should preserve readable content and usable navigation.
4. Test the site as a connected set of files
Open the home page in a browser and follow every link. Then start directly on the work page and return home. A working homepage is not sufficient if another page depends on a path that only works from the root.
If you already have Python installed, you can serve this simple project locally by opening a terminal in the project folder and running how to rank in ai search results python -m http.server 8000 --bind 127.0.0.1. Visit http://127.0.0.1:8000/ on that computer, and stop the server with Ctrl+C afterward. This is a local preview, not public hosting.
For this article, the supplied files received local structural and loopback-HTTP checks. Those checks cover links, assets, and retrieval under a folder prefix; they do not establish visual quality, assistive-technology compatibility, or production security. Perform browser checks at narrow widths and with keyboard navigation before treating the site as ready.
Next action: Review a technical SEO checklist after the basic pages work. Keep crawlability checks separate from claims that the site will rank.
5. Publish to hosting that matches static files
MDN's publishing guide distinguishes local work from making a site available through hosting. Uploading files and registering a domain are related decisions, but a domain purchase alone does not serve the site.
GitHub Pages is one documented static-hosting option for HTML, CSS, and JavaScript. Check its current eligibility, usage restrictions, and publishing instructions for your intended project. Static hosting does not turn this example into a server-side application.
Publish only files intended to be public, including files copied from the project folder: a public repository can expose material that never appears on the visible page. Keep passwords, private customer data, and secret credentials out of the project. After deployment, visit the actual address, test both pages, and check the stylesheet request. This tutorial does not claim that a deployment was performed.
6. Add features in response to a real need
The sample has no form because a form needs a real submission destination and handling process. Adding input boxes without that process can make a website look functional while losing messages. Define what should happen after submission before selecting an implementation.
Similarly, add JavaScript for a task you can describe and test. A portfolio does not need a framework simply to display two text pages. Accounts, payments, and private data introduce requirements beyond this starter exercise and may justify a different architecture.
Next action: Plan the rest of your website setup, including updates, account responsibility, and backups. CMSSOP's website content guide can help turn the fictional page into an accurate explanation of real work.
Frequently asked questions
Do I need JavaScript to code my own website?
Not for this small text-based site. HTML supplies the content and links, while CSS styles them. Introduce JavaScript when a defined interaction requires it, and keep essential information available when possible if scripting fails.
Why does the website work locally but lose styling online?
Check the uploaded files, capitalization, relative paths, and the host's publishing directory. A local environment may hide a filename mismatch. Inspect the failed stylesheet request rather than assuming the entire site needs to be rebuilt.
Can I put my private API key in the HTML?
No. Code delivered to a visitor's browser must be treated as visible to that visitor. A feature requiring a secret needs an appropriate server-side or managed-service design. Do not publish a secret to make a demonstration appear complete.
Is this sample a complete professional website?
No. It demonstrates connected pages and a shared stylesheet. Real projects need accurate content, suitable features, accessibility review, browser testing, hosting configuration, and an ongoing maintenance plan appropriate to their purpose.
Will hand-coding make the website rank better?
Hand-coding alone does not establish a ranking advantage. Focus on useful content, usable pages, and technically accessible delivery. Evaluate search performance with evidence after publishing rather than promising a position from the choice of coding method.