Front-End 防爆小組
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Owners
          • Signed-in users
          • Everyone
          Owners Signed-in users Everyone
        • Write
          • Owners
          • Signed-in users
          • Everyone
          Owners Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Help
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Write
    Owners
    • Owners
    • Signed-in users
    • Everyone
    Owners Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Explain what a single page app is and how to make one SEO-friendly. *[SSR]: Server-Side Rendering *[CSR]: Client-Side Rendering *[SPA]: Single Page Application *[MPA]: Multi Page Application ## 什麼是 SPA (單頁式應用)? 早期的網站都是以靜待網頁/多頁式網頁 MPA 為主, ==從Server端渲染好網頁程式(HTML),再傳送到client端== ,當使用者點擊到其他頁面或是導航到其它 URL 時,網頁整個頁面會刷新,server會為新頁面發送新的 HTML,這也就是 SSR 伺服器渲染. 2004年Gmail問世,Gmail 充分利用了瀏覽器的 XMLHttpRequest,透過這個 API 送出 Request,再透過 JavaScript 變更目前畫面上的內容!就不會造成網頁整個刷新了!(其實就是之前談到的AJAX技術帶來的改變~前端分擔了伺服器端的工作,降低了伺服器的運算效能消耗及資料吞吐量,伺服器端 MVC 中 View 的部分,交給了前端來處理,取得資料、處理畫面、頁面跳轉...等等,讓網站使用像是使用應用程式一樣流暢) 網頁應用程式Web Applicaiton/單頁式網頁 SPA 開始崛起, CSR 客戶端渲染取而代之,==程式傳送到Client才產生HTML==,所以一開始Client收到的HTML,只有一些網頁的基本架構(如下圖),主要的實際內容要由js檔去取得,瀏覽器需要下載大量 JavaScript 檔案後,才計算、渲染畫面,導致首次訪問網站時需要較長的反應時間,好處是後續的網頁互動會很快。 ![](https://i.imgur.com/LPjZmx2.png) 回到首次訪問網站時,只下載一個沒有實際內容的架構,導致搜尋引擎的爬蟲爬到的也只是一個空殼,SEO面臨了極大的挑戰! :::warning SSR 跟 CSR 的主要差別在於網頁是在哪裡被渲染的 ::: ### SSR vs CSR #### Server-Side Rendering * 傳統網頁渲染的方式,從Server產生HTML後,再傳送到Client。 * 頁面由伺服器產生,每次更新頁面都需要全畫面重新渲染。 * 伺服器取得資料後,需要計算畫面並整頁送出,運算及流量的負荷都太大。 #### Client-Side Rendering * Modern web的網頁開發框架主要是以CSR為主,通常是SPA的網頁開發框架。 * 程式傳送到Client才產生HTML,所以一開始Client收到的HTML,幾乎是一張白紙,只有進入點(root)。 * SPA藉由先傳送程式碼到Client,來增加Client瀏覽網站的流暢度,在某些情境可以加速載入。 ![](https://i.imgur.com/uvPqNky.png) ![](https://i.imgur.com/eF8OxN6.png) ![](https://i.imgur.com/7ZL2n1a.png) SSR網站更快的渲染,而CSR有一段空白在下載檔案 ![](https://i.imgur.com/wVv0zaJ.png) SSR檔案大,CSR回覆更快(這個範例出於某種原因主頁除外) ## CSR的SEO問題? ### 對html做設定.. html架構是會被讀取到的,所以我們可以在html設定,meta標籤,網頁分享的og (open graph),Keywords,壓縮圖片大小、loading 速度,JSON-LD(JavaScript Object Notation for Linked Data)等等等 [SEO Site ckeckup](https://seositecheckup.com/) [如何加強網站的SEO - 基礎篇](https://blog.yyisyou.tw/5ac95a76/) [如何加強網站的SEO - 進階篇](https://blog.yyisyou.tw/68015a49/) ### Isomorphic ( universal ) JavaScript 同構/通用的JavaScript概念 由於要達到SSR效果的目的是為了要讓Search engine讀懂網站的內容是什麼,並非真的要產生網站給Search engine使用,因此只要先寫好Client和Server共用的程式碼,並且在Server就把Client-side的程式碼跑過一遍,就可以達到目的了。 講白一點就是只會render一半,再傳給Client進行完整render的動作,因此流暢度也有明顯的提升。雖然是半殘的SSR,但是為了方便,其實很多人還是會直接叫SSR,而不會叫同構,這是為了方便溝通而稱呼的。 缺點就是開發技術含量很高,不止需要處理Client和Server的程式碼,還要了解Webpack的相依套件如何處理Server渲染的問題。 也就是第一畫面為 SSR,其他畫面是 CSR ### SSR 框架(Next,Nuxt) 在這樣的概念出來後,前端框架的 SSR 框架就出來了!也就是React的Next 或 Vue的Nuxt,是原本前端框架的語法再擴充,讓原先就熟悉框架的開發者,只需要越過相對小的進入門檻,就能滿足第一頁 SSR 的需求。 ### Prerender 之類的工具 在一些資料相對簡單,變動不太大的網站,也可以選擇透過例如 Prerender 之類的工具,是先把網頁全部算好,儲存成靜態頁面,這樣也可以解決 SEO 的問題。 #### 參考文章: [ 為什麼網站要做成 SPA?SSR 的優點是什麼?](https://medium.com/schaoss-blog/%E5%89%8D%E7%AB%AF%E4%B8%89%E5%8D%81-18-fe-%E7%82%BA%E4%BB%80%E9%BA%BC%E7%B6%B2%E7%AB%99%E8%A6%81%E5%81%9A%E6%88%90-spa-ssr-%E7%9A%84%E5%84%AA%E9%BB%9E%E6%98%AF%E4%BB%80%E9%BA%BC-c926145078a4) [如何加強網站的SEO - 基礎篇](https://blog.yyisyou.tw/5ac95a76/) [如何加強網站的SEO - SSR與CSR篇](https://blog.yyisyou.tw/ff55dd91/) [SPA和MPA網站區別,SEO優缺點剖析,甚麼時候該用那個?](https://www.leunghoyin.hk/spa-vs-mpa) [SSR vs CSR](https://dev.to/alain2020/ssr-vs-csr-2617#:~:text=the%20first%20request.-,the%20difference,client%20requests%20a%20different%20route.) [A Closer Look at Client-Side & Server-Side Rendering](https://www.growth-rocket.com/blog/a-closer-look-at-client-side-server-side-rendering/) [The Benefits of Server Side Rendering Over Client Side Rendering](https://medium.com/walmartglobaltech/the-benefits-of-server-side-rendering-over-client-side-rendering-5d07ff2cefe8) [說說SEO相關的話題,SPA單頁面對於SEO的優化的問題以及解決方案](https://kknews.cc/zh-tw/code/22gap5z.html) [[IT 鐵人賽] 為何我不用 SSR? Day 18](https://blog.hinablue.me/2019-ithome-ironman-day-18/) [搜尋引擎最佳化 (SEO) 入門指南](https://developers.google.com/search/docs/beginner/seo-starter-guide?hl=zh-tw) ### 補充: MPA vs SPA #### MPA * 內容代碼完整,搜尋引擎爬蟲就能夠輕鬆讀取網站內容然後放到適當的搜尋結果中,所以MPA對SEO友善 * 到新頁時網站會從頭到尾,整頁刷新一次,讓瀏覽器可以取得該新頁完整內容代碼 * 合適的網站:需要安全性較高,SEO是必需的應用。例如:部落格、電商平台網站、公司資料/產品網站 #### SPA * 除了第一次是全頁下載,之後的都是部份更新 * 訪問高效、更高開發效率、更方便維護 * 第一次看SPA網站要下載東西比較多,所以速度較慢。往後網頁互動就會很快,因為請求的資料量很少。 * 由於內容代碼不完整,搜尋引擎不一定能讀取,就算能讀取,也不是能百份百讀取到,對SEO不友好。 * 合適的網站:即時反應速度要快的應用。例如:社交網站、網上聊天室、股票報價、後台管理系統

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully