Skip to content

Study Guide: Project Setup & Tools

VS Code คือ code editor ที่นักพัฒนาส่วนใหญ่ใช้ — ฟรี, เร็ว, มี extensions เยอะมาก

  1. ไปที่ code.visualstudio.com
  2. ดาวน์โหลดตาม OS (Mac / Windows / Linux)
  3. เปิดแล้วติดตั้ง extensions ด้านล่าง
Extensionทำอะไร
Prettierจัดรูปแบบโค้ดให้สวยอัตโนมัติ
Live Serverเปิดหน้าเว็บแล้วรีเฟรชอัตโนมัติเมื่อบันทึก
Auto Rename Tagเปลี่ยนชื่อ tag เปิด tag ปิดจะเปลี่ยนตาม
Thai Language Packแปลเมนูเป็นภาษาไทย (optional)

กด Cmd + , เปิด Settings

settings.json
{
"editor.formatOnSave": true,
"editor.tabSize": 2,
"editor.wordWrap": "on",
"editor.minimap.enabled": false
}

ตั้งชื่อไฟล์ยังไงดี?

Section titled “ตั้งชื่อไฟล์ยังไงดี?”
  • Directorymy-project/
    • index.html ใช้ lowercase + dash
    • style.css ชื่อสื่อความหมาย
    • script.js สั้น กระชับ
  • ใช้ lowercase เสมอ
  • ใช้ dash (-) แทน space
  • ชื่อต้อง สื่อความหมาย (ไม่ใช่ test1.html, aaa.css)
  • ทุกโปรเจกต์เริ่มจาก index.html เป็นหน้าหลัก
นามสกุลคืออะไร
.htmlโครงสร้างหน้าเว็บ
.cssตกแต่ง style
.jsใส่ logic + interactive
.jsonเก็บข้อมูล config
.mdเขียนเอกสาร (README)

Terminal คือที่ที่เราพิมพ์คำสั่งแทนการคลิก — เปิดได้ใน VS Code โดยกด Ctrl + `

Terminal
# ดูว่าอยู่ที่ไหน
pwd
# ดูไฟล์ในโฟลเดอร์ปัจจุบัน
ls
# เข้าไปในโฟลเดอร์
cd my-project
# ย้อนกลับ 1 ขั้น
cd ..
# สร้างโฟลเดอร์ใหม่
mkdir my-project
# สร้างไฟล์ใหม่
touch index.html
# เคลียร์หน้าจอ
clear

ตัวอย่าง: สร้างโปรเจกต์ใหม่

Section titled “ตัวอย่าง: สร้างโปรเจกต์ใหม่”
Terminal window
mkdir hello-world
cd hello-world
touch index.html style.css
code . # เปิดโฟลเดอร์ใน VS Code

Git คือ version control — เหมือนกด Save Game ในเกม กลับไปจุดเดิมได้เสมอ

git add git commit Working Directory(แก้ไข) Staging Area(เตรียม) Repository(บันทึก)

คำสั่งที่ใช้บ่อย

Section titled “คำสั่งที่ใช้บ่อย”
Terminal
# เริ่มใช้ Git ในโปรเจกต์
git init
# ดูสถานะ (ไฟล์ไหนเปลี่ยน, ไหนยังไม่ track)
git status
# เพิ่มไฟล์เข้า staging
git add index.html # เพิ่มไฟล์เดียว
git add . # เพิ่มทุกไฟล์
# บันทึก (commit)
git commit -m "add homepage"
# ดูประวัติ
git log --oneline
Terminal window
# เชื่อม local กับ remote (ทำครั้งแรกครั้งเดียว)
git remote add origin https://github.com/username/repo-name.git
# Push โค้ดขึ้น GitHub
git push -u origin main

สร้างไฟล์ .gitignore เพื่อบอก Git ว่าไฟล์ไหนไม่ต้อง track:

.gitignore
node_modules/
.DS_Store
*.log
.env

  1. ไปที่ github.com แล้ว sign up / login
  2. กดปุ่ม New สร้าง repository ใหม่
  3. ตั้งชื่อ repo (เช่น hello-world)
  4. อย่า ติ๊ก “Add a README” (เพราะเรามีไฟล์แล้ว)
  5. กด Create repository
  6. ทำตามคำสั่งที่ GitHub แสดง (git remote add + git push)
  1. ไปที่ Settings ของ repository
  2. เลือก Pages ในเมนูซ้าย
  3. ที่ Source เลือก Deploy from a branch
  4. เลือก branch main แล้วกด Save
  5. รอ 1-2 นาที เว็บจะขึ้นที่ https://username.github.io/repo-name

DevTools คือเครื่องมือตรวจสอบหน้าเว็บที่ซ่อนอยู่ใน browser

เปิดด้วย Cmd + Option + I หรือ F12

Elements Panel — ตรวจสอบ HTML/CSS

Section titled “Elements Panel — ตรวจสอบ HTML/CSS”
  • ดูโครงสร้าง HTML ของหน้าเว็บ
  • แก้ไข CSS ได้แบบ live (ไม่กระทบไฟล์จริง)
  • ดู Box Model (margin, border, padding, content)
  • คลิกขวาที่ element > Inspect
Console
// ลองพิมพ์ใน Console
document.title
document.querySelector("h1").textContent
2 + 2

Responsive Mode — ทดสอบหน้าจอต่างขนาด

Section titled “Responsive Mode — ทดสอบหน้าจอต่างขนาด”

กดปุ่มรูปมือถือ (หรือ Cmd + Shift + M) เพื่อจำลอง��น้าจอ mobile, tablet, desktop


เว็บทำงานยังไง?

Section titled “เว็บทำงานยังไง?”
1. พิมพ์ URL แล้ว request 2. ส่ง HTML, CSS, JS กลับมา 3. Browser อ่าน HTML → สร้างโครงสร้าง 4. อ่าน CSS → ใส่ style 5. อ่าน JS → เพิ่ม interactive 6. แสดงหน้าเว็บ! User (Browser) Server

บทบาทของแต่ละภาษา

Section titled “บทบาทของแต่ละภาษา”
ภาษาบทบาทเปรียบเทียบ
HTMLโครงสร้างโครงกระดูก
CSSตกแต่งเสื้อผ้า, แต่งหน้า
JavaScriptพฤติกรรมกล้ามเนื้อ, การเคลื่อนไหว

การตั้งชื่อไฟล์

Section titled “การตั้งชื่อไฟล์”
my-portfolio/index.html ← lowercase, dash, สื่อความหมาย
Terminal
# Good — บอกว่าทำอะไร สั้นกระชับ
git commit -m "add navigation bar"
git commit -m "fix responsive layout on mobile"
git commit -m "update hero section text"

เมื่อไหร่ควร Commit?

Section titled “เมื่อไหร่ควร Commit?”
  • ทำฟีเจอร์เสร็จ 1 อัน → commit
  • แก้ bug เสร็จ → commit
  • อย่า commit ทีเดียวทั้งโปรเจกต์ — แบ่ง commit ย่อยๆ