Panduan lengkap setup website statis dengan HTML/CSS, dari pemilihan template hingga deployment ke hosting.
1. Pexels, Unsplash, Pixabay
2. HTML5 Up
3. Bootstrap Templates
4. Tailwind Templates
5. Envato Elements / ThemeForest
<!DOCTYPE html>
<html lang="id">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Website Saya</title>
<link rel="stylesheet" href="styles/main.css">
</head>
<body>
<header>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
<li><a href="#services">Services</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section id="home">
<h1>Welcome</h1>
</section>
</main>
<footer>
<p>© 2024 Website Saya</p>
</footer>
</body>
</html>
# Extract template
unzip template-html.zip
cd template-html
# Lihat struktur folder
ls -la
project/
├── index.html # Home page
├── about.html # About page
├── services.html # Services page
├── contact.html # Contact page
│
├── css/
│ ├── style.css # Main stylesheet
│ ├── responsive.css # Mobile responsive
│ └── normalize.css # Browser normalization
│
├── js/
│ ├── main.js # Main JavaScript
│ ├── jquery.min.js # jQuery (jika diperlukan)
│ └── bootstrap.min.js # Bootstrap JS
│
├── images/
│ ├── logo.png
│ ├── hero.jpg
│ └── icons/
│
├── fonts/
│ ├── roboto.woff2
│ └── opensans.woff2
│
├── assets/
│ └── downloads/
│
└── README.md
# Jika menggunakan VS Code
# 1. Install "Live Server" extension
# 2. Right-click pada index.html
# 3. Select "Open with Live Server"
# Atau dengan Python
python3 -m http.server 8000
# Akses di http://localhost:8000
<!-- Ubah judul website -->
<title>Nama Website Saya</title>
<!-- Ubah logo -->
<img src="images/my-logo.png" alt="Logo">
<!-- Ubah teks -->
<h1>Selamat Datang di Website Saya</h1>
<p>Deskripsi website saya di sini</p>
Edit css/style.css:
/* Root variables untuk color consistency */
:root {
--primary-color: #3498db;
--secondary-color: #2ecc71;
--text-dark: #2c3e50;
--bg-light: #ecf0f1;
}
/* Gunakan variables */
body {
color: var(--text-dark);
background-color: var(--bg-light);
}
.btn-primary {
background-color: var(--primary-color);
}
/* Desktop first (dari besar ke kecil) */
.container {
max-width: 1200px;
margin: 0 auto;
padding: 20px;
}
/* Tablet - 768px and down */
@media (max-width: 768px) {
.container {
padding: 15px;
}
.grid {
grid-template-columns: 1fr 1fr;
}
}
/* Mobile - 480px and down */
@media (max-width: 480px) {
.container {
padding: 10px;
}
.grid {
grid-template-columns: 1fr;
}
nav ul {
flex-direction: column;
}
}
// File: js/mobile-menu.js
document.addEventListener('DOMContentLoaded', function() {
const hamburger = document.querySelector('.hamburger');
const nav = document.querySelector('nav ul');
hamburger.addEventListener('click', function() {
nav.classList.toggle('active');
});
});
HTML:
<header>
<button class="hamburger">☰</button>
<nav>
<ul>
<li><a href="#home">Home</a></li>
<li><a href="#about">About</a></li>
</ul>
</nav>
</header>
CSS:
.hamburger {
display: none;
background: none;
border: none;
font-size: 24px;
cursor: pointer;
}
@media (max-width: 768px) {
.hamburger {
display: block;
}
nav ul {
display: none;
flex-direction: column;
}
nav ul.active {
display: flex;
}
}
// File: js/form-validation.js
document.getElementById('contactForm').addEventListener('submit', function(e) {
e.preventDefault();
const email = document.getElementById('email');
const name = document.getElementById('name');
// Simple validation
if (name.value.trim() === '') {
alert('Nama tidak boleh kosong');
return;
}
if (email.value.indexOf('@') === -1) {
alert('Email tidak valid');
return;
}
// Send form
console.log('Form submitted:', {
name: name.value,
email: email.value
});
});
// Smooth scroll untuk anchor links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
});
});
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Deskripsi website untuk search engine">
<meta name="keywords" content="keyword1, keyword2, keyword3">
<meta name="author" content="Nama Penulis">
<!-- Open Graph untuk social media -->
<meta property="og:title" content="Judul Website">
<meta property="og:description" content="Deskripsi">
<meta property="og:image" content="images/og-image.jpg">
<meta property="og:url" content="https://website.com">
<title>Judul Website | Subtitle</title>
</head>
<!-- BAIK - Semantic -->
<header>
<nav>Navigation</nav>
</header>
<main>
<article>
<h1>Judul Artikel</h1>
<p>Konten artikel</p>
</article>
</main>
<footer>
<small>© 2024</small>
</footer>
<!-- TIDAK BAIK - Non-semantic -->
<div id="header">
<div id="nav">Navigation</div>
</div>
<!-- Gunakan sizes untuk responsive images -->
<img
src="images/hero.jpg"
alt="Deskripsi gambar"
title="Judul gambar"
loading="lazy"
width="1200"
height="600"
>
<!-- Picture element untuk different formats -->
<picture>
<source srcset="images/hero.webp" type="image/webp">
<source srcset="images/hero.jpg" type="image/jpeg">
<img src="images/hero.jpg" alt="Hero">
</picture>
# Gunakan online minifiers
# https://www.minifier.org/
# https://cssminifier.com/
# Atau dengan CLI tools
npm install -g terser
terser js/main.js -o js/main.min.js
# Gunakan ImageMagick
convert large-image.jpg -resize 1200x600 optimized.jpg
# Online tools: TinyPNG, Compressor.io
<img
src="images/small.jpg"
data-src="images/large.jpg"
alt="Image"
loading="lazy"
>
/* Fallback untuk IE */
.grid {
display: -ms-grid; /* IE 10-11 */
display: grid;
}
.flex {
display: -webkit-box; /* Safari */
display: flex;
}
# HTML Validator
npm install -g html-validator-cli
html-validator index.html
# Accessibility check
npm install -g pa11y-ci
pa11y http://localhost:8000
# 1. Create GitHub repo
# 2. Push HTML files
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/username/repo.git
git push -u origin main
# 3. Enable Pages di GitHub Settings
# 4. Website live di: https://username.github.io/repo
# Method 1: Drag & Drop
# 1. Buka netlify.com
# 2. Drag folder project ke area upload
# 3. Selesai!
# Method 2: CLI
npm install -g netlify-cli
netlify deploy --prod --dir=.
# 1. Compress folder
zip -r website.zip .
# 2. Login ke cPanel
# 3. File Manager → upload website.zip
# 4. Extract file
# 5. Edit index.html jika perlu
# 6. Website live di: https://domain.com
# Gunakan FileZilla atau WinSCP
# 1. Koneksi ke server via FTP
# 2. Upload semua files ke folder public_html
# 3. Verify permissions (chmod 644 untuk files, 755 untuk folders)
# 4. Website live
# 1. Install Vercel CLI
npm install -g vercel
# 2. Deploy
vercel
# 3. Website live di: https://[name].vercel.app
# Keep template updated
# 1. Check for security updates
# 2. Update external libraries
# 3. Test thoroughly before pushing to production
# Use CDN for libraries
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
<!-- Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=GA_MEASUREMENT_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'GA_MEASUREMENT_ID');
</script>
✅ GUNAKAN:
❌ HINDARI:
<b>, <i>, <center>)<!-- Pastikan path benar -->
<link rel="stylesheet" href="./css/style.css">
<!-- Check browser console untuk errors -->
<!-- F12 → Console tab -->
// Gunakan try-catch untuk error handling
try {
// code
} catch (error) {
console.error('Error:', error);
}
<!-- Pastikan viewport meta tag ada -->
<meta name="viewport" content="width=device-width, initial-scale=1.0">
Resources Berguna: