Luyện Phỏng Vấn IT — 2000+ Câu Hỏi Phỏng Vấn IT Có Đáp Án 2026
SEO
SEO (Search Engine Optimization) là tối ưu hóa website để đạt thứ hạng cao trên Google, Bing, và các công cụ tìm kiếm. 68% online experiences bắt đầu từ search engine — frontend developer ảnh hưởng trực tiếp đến khả năng index và rank của trang.
Frontend developer trực tiếp ảnh hưởng SEO vì:
- HTML structure quyết định cách Google hiểu nội dung (semantic tags, heading hierarchy)
- Performance ảnh hưởng ranking (Core Web Vitals là ranking signal từ 2021)
- Rendering strategy quyết định Google có index được content không (CSR vs SSR)
- Technical SEO implementation (meta tags, structured data, sitemap) thường do frontend làm
Có 5 meta tags quan trọng nhất mà frontend dev cần nắm: title, description, robots, canonical, và Open Graph.
Title tag (<title>): quan trọng nhất, hiển thị trên tab browser và kết quả tìm kiếm. Quy tắc: 50-60 ký tự, chứa keyword chính ở đầu, unique cho mỗi trang, format: 'Primary Keyword - Secondary | Brand'.
Meta description (<meta name='description'>): mô tả trang hiển thị dưới title trên Google. Quy tắc: 150-160 ký tự, chứa keyword tự nhiên, có call-to-action, unique.
Meta robots (<meta name='robots'>): điều khiển indexing — index,follow (mặc định), noindex (không index), nofollow (không follow links).
Canonical (<link rel='canonical'>): chỉ định URL chính thức khi có duplicate content.
Open Graph (og:title, og:description, og:image): kiểm soát preview khi share trên social media.
Semantic HTML giúp search engine hiểu cấu trúc và ý nghĩa nội dung, trực tiếp ảnh hưởng ranking — dùng <div> cho mọi thứ là cách nhanh nhất để giảm khả năng index.
Các thẻ quan trọng: <header> (phần đầu trang), <nav> (navigation — Google hiểu đây là menu), <main> (nội dung chính — Google ưu tiên index phần này), <article> (bài viết độc lập — có thể xuất hiện trong Google News), <section> (phần nội dung có chủ đề), <aside> (sidebar — Google biết đây không phải nội dung chính), <footer> (chân trang).
Heading hierarchy: chỉ 1 <h1> mỗi trang (chứa keyword chính), <h2> cho sections, <h3> cho sub-sections — Google dùng heading để hiểu topic hierarchy. Sai lầm phổ biến: dùng <div> cho mọi thứ, nhiều <h1>, skip heading levels (h1 → h3).
robots.txt là file text đặt ở root domain (example.com/robots.txt) hướng dẫn search engine bots nên/không nên crawl phần nào của website. Syntax: User-agent: * (áp dụng cho tất cả bots), Disallow: /admin (không crawl /admin), Allow: /admin/public (ngoại lệ cho phép), Sitemap: https://example.com/sitemap.xml.
Lưu ý quan trọng: robots.txt chỉ là 'yêu cầu', bot xấu có thể bỏ qua. Disallow KHÔNG giống noindex — trang vẫn có thể xuất hiện trên Google nếu có backlinks. Muốn chắc chắn không index → dùng <meta name='robots' content='noindex'>.
Sai lầm: block CSS/JS files khiến Google không render được trang → ảnh hưởng SEO nghiêm trọng.
Sitemap XML (sitemap.xml) là file liệt kê tất cả URLs quan trọng của website, giúp search engine khám phá và index nhanh hơn. Format: <urlset> chứa nhiều <url>, mỗi url có <loc> (URL), <lastmod> (ngày cập nhật), <changefreq> và <priority> — lưu ý Google đã giảm tầm quan trọng của hai trường này từ ~2022 (vẫn giữ cho tương thích).
Khi nào CẦN: website lớn (>500 trang), trang mới tạo chưa có backlinks, website có nhiều content động (blog, e-commerce), trang deep link (>3 clicks từ homepage). Khi nào KHÔNG cần: website nhỏ (<50 trang) với navigation tốt.
Trong Next.js: dùng app/sitemap.ts export function trả về mảng URLs — Next.js tự generate sitemap.xml. Giới hạn: max 50,000 URLs hoặc 50MB mỗi sitemap, dùng sitemap index cho website lớn hơn.
Canonical URL (<link rel='canonical' href='...'>) cho Google biết URL nào là 'bản gốc' khi có nhiều URLs chứa cùng nội dung.
Ví dụ: /products?sort=price và /products?sort=name cùng nội dung → canonical trỏ về /products. Khi nào CẦN:
- URL parameters tạo duplicate (filters, sort, pagination)
- HTTP vs HTTPS, www vs non-www
- Syndicated content (bài viết đăng trên nhiều site)
- Mobile URL khác desktop URL. Nếu không có canonical, Google tự chọn 'bản gốc' — có thể chọn sai. Trong Next.js: dùng
metadata.alternates.canonicaltronggenerateMetadata()
Lưu ý: canonical phải là absolute URL, self-referencing canonical cũng tốt (mỗi trang canonical trỏ về chính nó).
Alt text (alt attribute trên <img>) mô tả nội dung ảnh cho:
- Search engines — Google không 'nhìn' ảnh, dùng alt text để hiểu ảnh và rank trên Google Images,
- Screen readers — người khiếm thị nghe mô tả ảnh,
- Fallback — hiển thị khi ảnh không load được
Cách viết tốt: mô tả cụ thể, ngắn gọn (125 ký tự), chứa keyword tự nhiên (không keyword stuffing).
Ví dụ tốt: alt='Golden retriever puppy playing fetch in park'.
Ví dụ xấu: alt='dog', alt='image1.jpg', alt='best dog training tips buy now click here'.
Khi nào để trống (alt=''): decorative images không mang thông tin (icons, dividers, background patterns). Ảnh text (infographic, banner): alt text nên chứa text trong ảnh.
Rendering strategy là yếu tố critical ảnh hưởng khả năng Google index content — CSR là rủi ro cao nhất, SSR/SSG an toàn nhất.
CSR (Client-Side Rendering): HTML ban đầu trống, JS render content → Google phải chờ JS execute (second wave indexing). Rủi ro: Googlebot có thể timeout, content không index đầy đủ, crawl budget lãng phí.
SSR (Server-Side Rendering): HTML đầy đủ từ server → Google index ngay lập tức, tốt nhất cho SEO.
SSG (Static Site Generation): HTML pre-built → nhanh nhất, SEO tuyệt vời cho content tĩnh.
Google crawl SPA: Googlebot dùng Chromium headless, render JS rồi mới index — nhưng có hàng đợi dài (render queue), có thể mất vài ngày đến vài tuần. Nếu bắt buộc CSR: đảm bảo critical content trong initial HTML, dùng dynamic rendering cho bot.
Core Web Vitals (CWV) là 3 metrics đo trải nghiệm người dùng, là ranking signal của Google từ 2021. INP thay thế FID từ tháng 3/2024.
LCP (Largest Contentful Paint): thời gian render phần tử lớn nhất (hero image, heading) — target: <2.5s. Cải thiện: optimize images (WebP, lazy load), preload fonts, SSR/SSG.
INP (Interaction to Next Paint): thời gian phản hồi khi user interact (click, tap) — target: <200ms. Cải thiện: code split, defer heavy JS, reduce main thread work.
CLS (Cumulative Layout Shift): mức độ layout bị 'nhảy' — target: <0.1. Cải thiện: set width/height cho images/videos, font-display swap, avoid dynamic content injection above fold.
Google Search Console báo CWV cho từng URL. Trang có CWV tốt được ưu tiên ranking khi 2 trang có relevance tương đương.
Structured Data (JSON-LD) là cách mark up content để Google hiểu semantic context và show Rich Snippets — tăng CTR đáng kể không cần thay đổi ranking. Format phổ biến: JSON-LD trong <script type='application/ld+json'>.
Lợi ích: Rich Snippets — kết quả tìm kiếm đặc biệt với rating stars, price, availability, FAQ accordion, breadcrumbs, sitelinks. CTR tăng 20-30% với rich snippets. Schema phổ biến cho frontend: Article (blog), Product (e-commerce), FAQPage (FAQ), BreadcrumbList (breadcrumbs), Organization (company info), WebSite (search box trong Google). Trong Next.js: tạo component <JsonLd> render <script> tag với JSON.stringify(data). Validate bằng Google Rich Results Test.
Open Graph và Twitter Cards kiểm soát preview khi share link trên social media — share preview đẹp → nhiều click → nhiều traffic → nhiều backlinks → ranking tăng gián tiếp.
Open Graph (OG): meta tags chuẩn Facebook để kiểm soát preview trên Facebook, LinkedIn, Zalo, Telegram. Tags quan trọng: og:title, og:description, og:image (1200x630px recommended), og:url, og:type.
Twitter Cards: tương tự OG nhưng cho Twitter/X — twitter:card ('summary_large_image' phổ biến nhất), twitter:title, twitter:description, twitter:image.
Trong Next.js App Router: dùng metadata export hoặc generateMetadata() — Next.js tự generate OG và Twitter meta tags. Dynamic OG images: dùng opengraph-image.tsx (hoặc @vercel/og) để generate image động chứa title, author, date.
Internal linking phân phối link equity và giúp Google khám phá trang — trang không có internal link nào trỏ đến là 'orphan page', có thể không bao giờ được index.
Ảnh hưởng SEO:
- Crawlability: Google khám phá trang mới qua internal links
- Link equity: trang được nhiều internal links trỏ đến sẽ rank cao hơn
- Context: anchor text của internal link giúp Google hiểu trang đích nói về gì
Best practices: dùng descriptive anchor text (không 'click here'), link từ high-authority pages đến important pages, sử dụng breadcrumbs, related posts, sidebar navigation. Trong React/Next.js: dùng <Link> component (không phải <a>) để SPA navigation nhưng vẫn render <a> cho SEO.
Next.js App Router Metadata API thay thế hoàn toàn react-helmet — type-safe, server-rendered, cascade từ layout xuống page.
2 cách dùng:
- Static metadata: export
const metadata: Metadata = { title: '...', description: '...' }từ layout.tsx hoặc page.tsx - Dynamic metadata: export
async function generateMetadata({ params }) { ... return { title, description } }— fetch data rồi generate meta tags
Metadata cascade: layout metadata → page metadata (page override layout). Tính năng: title.template (pattern cho child pages, ví dụ '%s | MyApp'), openGraph, twitter, robots, alternates (canonical, hreflang), icons (favicon), verification (Google Search Console).
Next.js tự động generate <title>, <meta>, OG tags, Twitter cards, canonical URL từ metadata object — không cần thư viện bên ngoài.
Next.js App Router tích hợp native sitemap và robots.txt với TypeScript type-safety — không cần plugin hay static files.
Sitemap: tạo app/sitemap.ts export default function trả về mảng MetadataRoute.Sitemap. Mỗi item có url, lastModified, changeFrequency, priority. Có thể fetch data từ DB/CMS để generate dynamic URLs. Cho website lớn: tạo app/sitemap/[id]/route.ts để generate multiple sitemaps (sitemap index).
robots.txt: tạo app/robots.ts export default function trả về MetadataRoute.Robots object với rules (User-Agent, allow, disallow) và sitemap URL.
Ví dụ: { rules: { userAgent: '*', allow: '/', disallow: '/admin/' }, sitemap: 'https://example.com/sitemap.xml' }. Cả 2 đều type-safe với TypeScript, auto-generate tại build time.
next/image tự động handle lazy loading, responsive srcset, WebP conversion, và CLS prevention — 5 tính năng trực tiếp cải thiện Core Web Vitals.
- Lazy loading mặc định — chỉ load khi gần viewport, giảm initial page weight
- Responsive images — tự generate srcset với nhiều sizes, browser chọn size phù hợp
- Format optimization — auto convert sang WebP/AVIF nếu browser hỗ trợ, giảm 30-50% file size
- Prevent CLS — bắt buộc width/height hoặc fill, tránh layout shift
- Priority loading — set
priority={true}cho LCP image (above-the-fold)
SEO impact: LCP cải thiện (ranking signal), CLS giảm (ranking signal), smaller images = faster page = better crawl experience. Luôn thêm alt text mô tả ảnh cho Google Image Search và accessibility.
URL là signal nhẹ cho Google hiểu nội dung, nhưng ảnh hưởng CTR đáng kể vì user đọc URL trước khi click — URL xấu mất click dù rank cao.
Best practices:
- Ngắn gọn, descriptive:
/blog/react-query-tutorialtốt hơn/blog/post?id=123 - Dùng hyphens (-) ngăn cách từ, KHÔNG dùng underscores (_) — Google coi hyphen là word separator, underscore không
- Lowercase only —
/Aboutvà/aboutlà 2 URLs khác nhau (duplicate content) - Tránh parameters khi có thể —
/products/shoestốt hơn/products?category=shoes
- Tránh thay đổi URL — nếu bắt buộc, 301 redirect URL cũ → mới
- Include keyword target — nhưng tự nhiên
- Tránh nested quá sâu —
/a/b/c/d/e/pagekém hơn/a/page
Trong Next.js: file-based routing tạo clean URLs tự động.
Crawl budget là số pages Googlebot crawl trong một khoảng thời gian — waste crawl budget bằng duplicate URLs hay redirect chains có thể khiến important pages không được index.
Gồm 2 yếu tố: Crawl rate limit (tốc độ crawl không gây quá tải server) và Crawl demand (Google muốn crawl bao nhiêu dựa trên popularity/freshness). Quan trọng khi website >10,000 pages.
Lãng phí crawl budget:
- duplicate content (URL parameters, www/non-www)
- soft 404s (trang trống return 200)
- redirect chains (A→B→C→D)
- infinite URL spaces (calendar, filters tạo vô hạn URL combinations)
Tối ưu: canonical tags, robots.txt block unnecessary paths, clean URL structure, sitemap chỉ chứa important pages, server response time <500ms, dùng 410 thay vì 404 cho permanently deleted pages. Lưu ý: rel=next/prev cho pagination đã bị Google deprecated từ tháng 3/2019 — không còn hiệu lực.
hreflang attribute cho Google biết trang nào dành cho ngôn ngữ/quốc gia nào — tránh duplicate content penalty khi có nhiều phiên bản ngôn ngữ. Format: <link rel='alternate' hreflang='vi' href='https://example.com/vi/page'>.
Quy tắc:
- Mỗi trang phải có hreflang trỏ đến TẤT CẢ phiên bản ngôn ngữ (kể cả chính nó — self-referencing).
- hreflang phải reciprocal (trang A trỏ B, trang B phải trỏ lại A).
- Dùng x-default cho fallback language.
Format language code: 'vi' (ngôn ngữ), 'en-US' (ngôn ngữ-quốc gia). Trong Next.js: cấu hình i18n routing trong next.config, generateMetadata() với alternates.languages.
Sai lầm: hreflang không reciprocal (Google bỏ qua), mixed signals (hreflang nói tiếng Việt nhưng content tiếng Anh), quên x-default.
JS SEO có 4 loại lỗi phổ biến khiến Google không index được content — rendering, meta tags, links, và resources.
Lỗi rendering:
- Content trong useEffect/componentDidMount — Google có thể không chờ async data fetch
- Client-only routing (React Router) không có SSR fallback — Google thấy blank page
- Error boundaries catch lỗi nhưng render fallback UI — Google index error message thay vì content
Lỗi meta tags:
- Dynamic title/description set bằng JS — Google có thể lấy title trước khi JS chạy
- Thiếu canonical cho dynamic routes
Lỗi links:
- Navigation bằng onClick + router.push thay vì
<a href>— Google không follow JS click events - Infinite scroll không có pagination fallback
Lỗi resources:
- robots.txt block JS/CSS bundles — Google không render được trang
- Bundle quá lớn khiến Googlebot timeout (>5s)
Fix chung: dùng SSR/SSG, test bằng Google Search Console URL Inspection, dùng <Link> component cho navigation.
Dynamic OG images là ảnh preview được generate tự động cho mỗi trang — thay vì 1 ảnh chung cho cả website. Dùng @vercel/og (Satori) hoặc Next.js convention file app/blog/[slug]/opengraph-image.tsx. Cơ chế: viết JSX/HTML → Satori convert sang SVG → convert sang PNG. Có thể fetch data (title, author, date) rồi render lên ảnh.
Ví dụ: blog post share trên Facebook hiển thị ảnh có title bài viết, author avatar, ngày đăng — professional hơn nhiều so với generic image. Performance: generate tại build time (SSG) hoặc on-demand (ISR), cache kết quả. CTR impact: trang có OG image đẹp và unique có CTR cao hơn 2-3x khi share trên social media.
generateStaticParams pre-render dynamic routes tại build time (SSG) → HTML sẵn sàng, Google index ngay, TTFB cực nhanh.
Ví dụ: blog có 100 posts → generate 100 static HTML pages. ISR (Incremental Static Regeneration): kết hợp tốt nhất của SSG và SSR — serve cached HTML, background revalidate sau N giây. SEO benefits:
- Fast TTFB → Google crawl nhanh hơn
- HTML đầy đủ → index ngay không cần render JS
- Luôn fresh content với revalidate. Pattern:
generateStaticParamscho known routes (categories, popular posts), fallback dynamic rendering cho routes mới (long-tail). Vớirevalidate: 3600(1 giờ): Google luôn thấy content mới nhất, users luôn thấy fast page
LCP đo thời gian render element lớn nhất trên viewport — optimize bằng cách xác định đúng LCP element rồi tối ưu theo loại: image, text, hay video poster.
Target: <2.5s. Xác định LCP element: dùng Chrome DevTools Performance tab hoặc web-vitals library.
Tối ưu theo loại:
- Image LCP:
priorityprop trong next/image, preload với<link rel='preload'>, avoid lazy load, dùng CDN, responsive sizes, WebP - Text LCP: font-display swap, preload font file, avoid web font nếu được (system font stack)
- Video poster: preload poster image
Server optimizations: reduce TTFB (<600ms) bằng SSG/ISR/edge functions, streaming SSR.
Tránh: redirect chains, render-blocking CSS/JS lớn, client-side data fetch trước khi render LCP, quá nhiều third-party scripts (analytics, chat widgets). Trong Next.js: next/image với priority, next/font với display: swap, App Router streaming.
SEO audit checklist cho frontend developer bao gồm 5 nhóm: Technical, Content, Performance, Structured Data, và Crawlability.
Technical:
- Tất cả pages return đúng status code (200, 301, 404)
- sitemap.xml valid và submitted lên Google Search Console
- robots.txt không block important resources
- Canonical tags đúng trên mọi trang
- HTTPS enabled
Content:
- Mỗi trang có unique title (50-60 chars) và meta description (150-160 chars)
- Đúng 1
<h1>chứa primary keyword - Images có alt text
- Internal links với descriptive anchor text
Performance:
- Core Web Vitals pass (LCP <2.5s, INP <200ms, CLS <0.1)
- Mobile-friendly
- No render-blocking resources
Structured Data:
- JSON-LD markup cho relevant schema types
- Validate qua Rich Results Test
Crawlability:
- No orphan pages
- No redirect chains/loops
- No duplicate content without canonical
Tools: Google Search Console (free, essential), Lighthouse, Screaming Frog (crawl audit), Ahrefs/SEMrush (backlinks, keywords).