????????本教程介紹了如何創建并管理一個基于GitHub Pages的個人網站。首先,需要在GitHub上創建一個遵循特定命名規則的新倉庫,例如用戶名.github.io,以便建立個人站點。接著,通過Fork一個開源模板代碼倉庫并添加index.html文件來構建主頁,編寫HTML代碼以創建網頁內容。此外,還可以選擇使用Markdown文件作為主頁,GitHub Pages將自動將其渲染為HTML。在修改個人內容時,可以在about.md文件中編輯個人描述,并提供了原始代碼示例。完成文件編輯后,需要提交更改并推送到GitHub倉庫。隨后,通過訪問https://用戶名.github.io,可以查看構建完成的個人網頁。為了進一步個性化網站,可以修改_config.yml文件中的網站設置,包括基本設置、作者信息、評論系統、搜索引擎優化、閱讀文件等。這些設置將影響整個網站的布局和功能,包括語言、標題、描述、作者信息和倉庫地址等。通過這些步驟,用戶可以創建并定制一個簡單的個人網頁,并根據需要添加更多的HTML和CSS來增強網頁的美觀性和功能。
1. 創建倉庫
????????首先,你需要在GitHub上創建一個新的倉庫。倉庫的名稱必須遵循特定的格式,對于個人站點,格式為用戶名.github.io
,其中用戶名
是你的GitHub賬戶名。例如,如果你的用戶名是kimi
,那么倉庫名應該是kimi.github.io
。為方便大家搭建自己的網站,此處給出一個開源的模板代碼倉庫:
點此獲取開源模板代碼
????????在項目頁面的右上角,你會看到一個“STAR”和"Fork"按鈕。先點擊STAR再點擊“Fork”,GitHub會將這個項目復制到你的GitHub賬戶下,創建一個新的倉庫,這個新倉庫會與原項目保持連接,但更改不會影響原項目。點擊"Fork"按鈕后,GitHub會彈出一個下拉菜單,讓你選擇將項目Fork到哪個GitHub賬戶下。如果你只有一個賬戶,通常這個步驟會自動完成。
? ? ?Fork操作完成后,瀏覽器會自動跳轉到你的新倉庫頁面。這個頁面的URL會顯示為你的GitHub用戶名加上.github.io
,例如https://github.com/你的用戶名/Chenbin_ZHANG.github.io
。
2. 添加文件
創建倉庫后,你可以添加一個文件作為你的主頁。通常,這個文件會是一個index.html
文件,你可以在其中編寫HTML代碼來創建你的網頁內容。你也可以使用Markdown文件(如index.md
),GitHub會自動將其渲染為HTML。
?1.添加index.html
文件
- 創建文件:在GitHub倉庫頁面,點擊“Add file”按鈕,然后選擇“Create new file”。
- 命名文件:在文件名輸入框中輸入
index.html
。 - 編寫HTML代碼:在打開的編輯器中,你可以開始編寫HTML代碼。一個基本的HTML頁面結構如下:
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>我的個人網頁</title>
</head>
<body><h1>歡迎來到我的個人網頁</h1><p>這里是一些關于我的信息。</p><!-- 這里可以添加更多的HTML內容,比如圖片、鏈接、列表等 -->
</body>
</html>
2. 提交和推送index.html
- 提交更改:編寫完HTML代碼后,你需要提交這個文件。在頁面底部,輸入提交信息,比如“Add index.html”,然后點擊“Commit changes”按鈕。
- 推送到GitHub:如果你使用的是命令行,你可以使用以下Git命令將本地更改推送到GitHub倉庫:
git add index.html
git commit -m "Add index.html"
git push origin main
3. 使用Markdown作為主頁
如果你更喜歡使用Markdown來編寫內容,GitHub Pages也支持將Markdown文件自動渲染為HTML。以下是使用Markdown作為主頁的步驟:
- 創建Markdown文件:在倉庫中創建一個名為
index.md
的文件。 - 編寫Markdown內容:在
index.md
文件中,使用Markdown語法編寫內容。例如:
# 我的個人網頁歡迎來到我的個人網頁。這里是一些關于我的信息。- 列表項1
- 列表項2
-
配置Markdown渲染:GitHub Pages默認會自動渲染
.md
文件為HTML,但你需要確保倉庫的設置中啟用了Jekyll(GitHub Pages的靜態站點生成器),因為默認情況下,只有以.md
結尾的文件才會被渲染。 -
提交和推送
index.md
:和index.html
一樣,提交并推送index.md
文件到你的GitHub倉庫。
4. 訪問你的網頁
提交并推送文件后,GitHub Pages會構建你的網站。構建完成后,你可以通過https://你的用戶名.github.io
來訪問你的個人網頁。
通過這些步驟,你可以創建一個簡單的個人網頁,并且可以根據需要添加更多的HTML和CSS來進一步美化和增強你的網頁功能。
3. 修改個人內容
????????在_pages中的about,md中對個人描述內容進行修改,其原始代碼如下:
---
permalink: /
title: "Chenbin ZHANG"
author_profile: true
redirect_from: - /about/- /about.html
---Chenbin Zhang, male, is an undergraduate student in the class of 2021, majoring in Intelligent Science and Technology at College of Automation & College of Artificial Intelligence, Nanjing University of Posts and Telecommunications. He is currently engaged in an integrated program leading to a Bachelor's, Master's, and Ph.D. in Control Science and Engineering. Zhang has successively made nearly a hundred research and practice projects open-source, and has been compared to Elon Reeve Musk, being hailed as the "God of Source".More details
======
The URL for Baidu Baike entries is:https://baike.baidu.com/item/%E5%BC%A0%E6%99%A8%E6%96%8C?fromModule=lemma_search-boxEducational Background
======
September 2021 - Present Nanjing University of Posts and Telecommunications Intelligent Science and Technology | Bachelor's Degree Major Ranking: 11/62
Skills Certificates: English Certificates (CET-4, CET-6), proficient in languages such as Python, C, and have relevant experience with development platforms like ISE Design, Jieliuchuang EDA.
Work Positions: Served as the publicity committee member of Class B210414, proficient in PPT creation and have extensive experience in article writing.Hands-on experience
======
March 2024 School-level Programming Project Design and Implementation of Intelligent Face Recognition Access Control System Project Leader
------
Utilized the OpenCV image processing library to capture images and construct face data. Based on the MindSpore platform developed by Huawei, designed relevant face recognition algorithms using the dlib algorithm. Achieved real-time image capture and face recognition, created a simple UI interface, and controlled components such as MLX90614, servos, and passive buzzers using Raspberry Pi 4B and Arduino UNO development boards to implement the face recognition access control system.November 2023 School-level Electronic Circuit Project Design Design of a Digital Pulse Width Modulation Pulse Signal Generator Project Leader
Utilized ISE Design to develop and create a pulse signal generator with adjustable pulse width, controlled by buttons, which can increase or decrease the duty cycle by 1% each time, displaying the duty cycle of the output pulse signal on a digital tube, and also showing the pulse width situation.May 2023 School-level Open Experimental Project Design and Implementation of a Laser Harp Main Participant
Designed and created a laser harp, programmed the microcontroller to control the production of different musical notes with laser beams and the display of LED lights, and it can play various music and adjust the volume.Honors and awards
======
Personal Honors: Huawei-Ministry of Education 2022-2023 Intelligent Infrastructure "Future Star", Outstanding Young Volunteer, Outstanding League Member, Nanjing University of Posts and Telecommunications 2022-2023 Comprehensive Progress Scholarship, Nanjing University of Posts and Telecommunications Advanced Individual.
Competition Achievements: 2024 U.S. Collegiate Mathematical Modeling Competition S Award, Nanjing University of Posts and Telecommunications 2024 "Challenge Cup" Competition Bronze Award, 2023 (15th) Mathematical Modeling Competition Third Prize, Second Smart City Technology Competition Third Prize, 2023 College Student Advertising Art Competition Third Prize, Third College Student Financial Literacy Competition First Prize, 2022 China Youth Giant Panda Guardian Plan Honorary Award.Scientific research projects
======
Led a key school-level STITP project: Research on Meteorological Forecasting Based on Graph Neural Networks.
Designed and constructed a GCN (Graph Convolutional Network) model, utilizing graph convolutional layers to capture local and global features. By optimizing the model, effectively integrated spatiotemporal information to achieve predictions of meteorological indicators for a future period, enhancing the accuracy of meteorological forecasting.
- permalink:?
/
?表示這個頁面是網站的主頁。 - title: "Chenbin ZHANG" 是網頁的標題。
- author_profile: true 表示顯示作者的個人資料。
- redirect_from: 表示從其他路徑(如
/about/
和/about.html
)訪問時,會自動重定向到這個頁面。
并且該內容提供了一個鏈接到張晨斌的百度百科條目。
4. 訪問你的網頁
提交并推送文件后,通常需要等待1到5分鐘,GitHub Pages服務會構建你的網站。之后,你可以通過https://用戶名.github.io
來訪問你的個人網頁。為此你需要修改該項目中的_config.yml
# Welcome to Jekyll!
#
# This config file is meant for settings that affect your entire site, values
# which you are expected to set up once and rarely need to edit after that.
# For technical reasons, this file is *NOT* reloaded automatically when you use
# `jekyll serve -l -H localhost`. If you change this file, please restart the
# server process.# Basic Site Settings
locale : "en-US"
title : "HOME PAGE"
title_separator : "-"
name : &name "Your Name"
description : &description "personal description"
url : https://ace-trump-tech.github.io/Chenbin_ZHANG.github.io/ # the base hostname & protocol for your site e.g. "https://[your GitHub username].github.io"
baseurl : "" # the subpath of your site, e.g. "/blog"
repository : "ace-trump-tech.github.io/Chenbin_ZHANG.github.io"# Site Author - The following control what appear as part of the author content on the side bar.
# If a field is blank the icon and link will not appear, otherwise it will be shown.
# Additional customization can be done by editing /_includes/author-profile.html
author:# Biographic informationavatar : "picture1.png"name : "Chenbin ZHANG"pronouns : # example: "she/her" bio : "an undergraduate student in the class of 2021, majoring in Intelligent Science and Technology at College of Automation & College of Artificial Intelligence, Nanjing University of Posts and Telecommunications."location : "Nanjing China"#employer : "Red Brick University"uri : # URLemail : "b21041417@njupt.edu.cn" # Academic websitesarxiv : # URL - Update with the correct link to your profilegooglescholar : "https://scholar.google.com/citations?user=PS_CX0AAAAAJ"impactstory : # URLorcid : "http://orcid.org/yourorcidurl"semantic : # URLpubmed : "https://www.ncbi.nlm.nih.gov/pubmed/?term=john+snow"researchgate : # URLscopus : # URL# Repositories and software developmentbitbucket : # Username - Update with your username on the sitecodepen : # Usernamedribbble : # Usernamegithub : "academicpages"kaggle : # Username stackoverflow : # User number or user number and name (i.e., use "1" or "1/jeff-atwood") # Social mediabluesky : "bsky.app" # Replace this with you Bluesky usernamefacebook : # Usernameflickr : # Usernamefoursquare : # Usernamegoodreads : # Usernamegoogle_plus : # Usernamekeybase : # Usernameinstagram : # Usernamelastfm : # Usernamelinkedin : # Usernamemastodon : # URLmedium : # URLpinterest : # Usernamesoundcloud : # Usernamesteam : # Usernametelegram : # URLtumblr : # Usernametwitter : # Username for X / Twittervine : # Usernameweibo : # Usernamewikipedia : # Usernamexing : # Usernameyoutube : # Usernamezhihu : # Username# Publication Category - The following the list of publication categories and their headings
publication_category:books:title: 'Books'# manuscripts:# title: 'Journal Articles' conferences:title: 'Conference Papers'# Site Settings
teaser : # filename of teaser fallback teaser image placed in /images/, .e.g. "500x300.png"
breadcrumbs : false # true, false (default)
words_per_minute : 160
future : true
read_more : "disabled" # if enabled, adds "Read more" links to excerpts
talkmap_link : false #change to true to add link to talkmap on talks page
comments:provider : # false (default), "disqus", "discourse", "facebook", "google-plus", "staticman", "custom"disqus:shortname :discourse:server : # https://meta.discourse.org/t/embedding-discourse-comments-via-javascript/31963 , e.g.: meta.discourse.orgfacebook:appid :num_posts : # 5 (default)colorscheme : # "light" (default), "dark"
staticman:allowedFields : ['name', 'email', 'url', 'message']branch : "gh-pages" # "master", "gh-pages"commitMessage : "New comment."filename : comment-{@timestamp}format : "yml"moderation : truepath : "_data/comments/{options.slug}"requiredFields : ['name', 'email', 'message']transforms:email : "md5"generatedFields:date:type : "date"options:format : "iso8601" # "iso8601" (default), "timestamp-seconds", "timestamp-milliseconds"
atom_feed:hide : false # change to true to hide the RSS feed in the footerpath : # blank (default) uses feed.xml# SEO Related
google_site_verification :
bing_site_verification :
alexa_site_verification :
yandex_site_verification :# Social Sharing
twitter:username : &twitter
facebook:username :app_id :publisher :
og_image : # Open Graph/Twitter default site image
# For specifying social profiles
# - https://developers.google.com/structured-data/customize/social-profiles
social:type : # Person or Organization (defaults to Person)name : # If the user or organization name differs from the site's namelinks: # An array of links to social media profiles# Analytics
analytics:provider : "false" # false (default), "google", "google-universal", "google-analytics-4", "custom"google:tracking_id :# Reading Files
include:- .htaccess- _pages- files
exclude:- "*.sublime-project"- "*.sublime-workspace"- .asset-cache- .bundle- .github- .jekyll-assets-cache- .sass-cache- assets/js/_main.js- assets/js/plugins- assets/js/vendor- CHANGELOG- Capfile- config- Dockerfile- Gemfile- Gruntfile.js- gulpfile.js- LICENSE- local- log- node_modules- package.json*- Rakefile- README- tmp- vendor
keep_files:- .git- .svn
encoding: "utf-8"
markdown_ext: "markdown,mkdown,mkdn,mkd,md"# Conversion
markdown: kramdown
highlighter: rouge
lsi: false
excerpt_separator: "\n\n"
incremental: false# Markdown Processing
kramdown:input: GFMhard_wrap: falseauto_ids: truefootnote_nr: 1entity_output: as_chartoc_levels: 1..6smart_quotes: lsquo,rsquo,ldquo,rdquoenable_coderay: false# These settings control the types of collections used by the template
collections:teaching:output: truepermalink: /:collection/:path/publications:output: truepermalink: /:collection/:path/portfolio:output: truepermalink: /:collection/:path/talks:output: truepermalink: /:collection/:path/# These settings control how pages and collections are included in the site
defaults:# _posts- scope:path: ""type: postsvalues:layout: singleauthor_profile: trueread_time: truecomments: trueshare: truerelated: true# _pages- scope:path: ""type: pagesvalues:layout: singleauthor_profile: true# _teaching- scope:path: ""type: teachingvalues:layout: singleauthor_profile: trueshare: truecomments: true# _publications- scope:path: ""type: publicationsvalues:layout: singleauthor_profile: trueshare: truecomments: true# _portfolio- scope:path: ""type: portfoliovalues:layout: singleauthor_profile: trueshare: truecomment: true# _talks- scope:path: ""type: talksvalues:layout: talkauthor_profile: trueshare: true# Sass/SCSS
sass:sass_dir: _sassstyle: compressed # http://sass-lang.com/documentation/file.SASS_REFERENCE.html#output_style# Outputting
permalink: /:categories/:title/
# paginate: 5 # amount of posts to show
# paginate_path: /page:num/
timezone: Etc/UTC # http://en.wikipedia.org/wiki/List_of_tz_database_time_zones# Plugins
plugins:- jekyll-feed- jekyll-gist- jekyll-paginate- jekyll-sitemap- jekyll-redirect-from- jemoji# Mimic GitHub Pages with --safe
whitelist:- jekyll-feed- jekyll-gist- jekyll-paginate- jekyll-sitemap- jekyll-redirect-from- jemoji# Archives
# Type
# - GitHub Pages compatible archive pages built with Liquid ~> type: liquid (default)
# - Jekyll Archives plugin archive pages ~> type: jekyll-archives
# Path (examples)
# - Archive page should exist at path when using Liquid method or you can
# expect broken links (especially with breadcrumbs enabled)
# - <base_path>/tags/my-awesome-tag/index.html ~> path: /tags/
# - <base_path/categories/my-awesome-category/index.html ~> path: /categories/
# - <base_path/my-awesome-category/index.html ~> path: /
category_archive:type: liquidpath: /categories/
tag_archive:type: liquidpath: /tags/
# https://github.com/jekyll/jekyll-archives
# jekyll-archives:
# enabled:
# - categories
# - tags
# layouts:
# category: archive-taxonomy
# tag: archive-taxonomy
# permalinks:
# category: /categories/:name/
# tag: /tags/:name/# HTML Compression
# - http://jch.penibelst.de/
compress_html:clippings: allignore:envs: development
基本網站設置
locale
: 網站的語言設置,這里是“en-US”。title
: 網站的標題,這里是“HOME PAGE”。title_separator
: 標題分隔符,這里是“-”。name
: 網站作者的名字,這里使用了一個YAML錨點(&name)。description
: 網站的描述,這里也使用了YAML錨點(&description)。url
: 網站的基地址,這里是GitHub Pages的地址。baseurl
: 網站的子路徑,這里沒有子路徑。repository
: GitHub倉庫的地址。
5. 自定義主題(可選)
????????GitHub Pages 默認提供了一些靜態的主題供用戶選擇,但如果你想要更豐富的自定義功能,你可能需要使用第三方主題或者自己編寫樣式。以下是一些代碼示例,幫助你自定義 GitHub Pages 網站的外觀。
1.使用第三方主題
????????選擇主題 在倉庫的 Settings
頁面中找到 Pages
選項,點擊 Change Theme
來選擇一個你喜歡的主題。
????????添加主題到你的倉庫 如果你找到了一個第三方的主題,通常你需要下載該主題的壓縮包,并將其解壓到你的倉庫中。例如,假設你下載了一個名為 theme-name
的主題,你需要將該主題文件夾上傳到你的倉庫中。
2.自定義樣式
????????創建或修改 CSS 文件 你可以創建一個 main.css
文件在你的倉庫的 assets/css/
目錄下(如果沒有這個目錄,你需要創建它)。以下是一些基本的樣式代碼:
/* assets/css/main.css */
body {font-family: 'Arial', sans-serif;background-color: #f4f4f4;color: #333;
}.container {width: 80%;margin: auto;overflow: hidden;
}header {background: #50b3a2;color: white;padding: 20px;text-align: center;
}header h1 {margin: 0;
}footer {background: #333;color: white;text-align: center;padding: 10px;position: absolute;bottom: 0;width: 100%;
}
????????更新 _config.yml
文件 你需要在 _config.yml
文件中指定自定義樣式文件的路徑:
# _config.yml
sass:style: compressed
????????在布局文件中鏈接 CSS 在你的布局文件(例如 default.html
)中,鏈接到你的 CSS 文件:
<!-- _layouts/default.html -->
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>{{ site.title }}</title><link rel="stylesheet" href="{{ '/assets/css/main.css' | relative_url }}">
</head>
<body>{{ content }}
</body>
</html>
????????通過這些步驟,你可以自定義你的 GitHub Pages 網站的外觀。請注意,自定義樣式可能會覆蓋主題的一些默認樣式,因此你可能需要根據主題的具體結構進行調整。
6. 添加項目演示(可選)
要在你的GitHub Pages網站上展示你的項目,你需要將項目的靜態文件添加到倉庫中,并確保它們可以通過網頁訪問。以下是一些步驟和示例代碼,幫助你完成這個過程。
1. 創建項目目錄
首先,在倉庫的根目錄下創建一個新的文件夾來存放你的項目文件。例如,你可以創建一個名為 projects
的文件夾。
mkdir projects
2. 添加項目文件
將你的項目文件(HTML、CSS、JavaScript等)添加到這個新創建的 projects
文件夾中。例如:
projects/project1/index.html
projects/project1/style.css
projects/project1/script.js
3. 創建項目索引頁面
你可能希望在主頁上有一個鏈接到你的項目頁面的列表。在你的 index.html
或者其他主頁布局文件中,添加以下代碼:
<!-- index.html -->
<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>{{ site.title }}</title><link rel="stylesheet" href="{{ '/assets/css/main.css' | relative_url }}">
</head>
<body><h1>My Projects</h1><ul><li><a href="/projects/project1/">Project 1</a></li><!-- Add more projects here --></ul>{{ content }}
</body>
</html>
4. 更新?_config.yml
?文件
確保Jekyll會包含 projects
目錄下的文件,并為它們生成網頁。在 _config.yml
文件中添加:
# _config.yml
include:- projects
5. 提交并推送更改
使用Git命令行提交并推送更改到GitHub:
git add .
git commit -m "Add project directory"
git push origin main
6. 示例項目頁面代碼
以下是一個簡單的項目頁面 index.html
文件示例,它展示了如何組織項目內容。
<!-- projects/project1/index.html -->
---
layout: default
title: Project 1
---<!DOCTYPE html>
<html lang="en">
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>Project 1</title><link rel="stylesheet" href="{{ '/projects/project1/style.css' | relative_url }}">
</head>
<body><h1>Project 1</h1><p>This is a description of Project 1.</p><!-- You can include images, videos, or other media here --><img src="{{ '/projects/project1/screenshot.png' | relative_url }}" alt="Project 1 Screenshot"><script src="{{ '/projects/project1/script.js' | relative_url }}"></script>
</body>
</html>
7. 自定義項目頁面樣式
在 style.css
文件中,你可以添加自定義樣式來美化你的項目頁面:
/* projects/project1/style.css */
body {font-family: 'Arial', sans-serif;background-color: #f4f4f4;color: #333;
}.container {width: 80%;margin: auto;overflow: hidden;
}h1 {color: #333;text-align: center;
}img {max-width: 100%;height: auto;
}
通過這些步驟和代碼示例,你可以在你的GitHub Pages網站上展示你的項目,并為每個項目創建一個專門的頁面。這樣,訪問者可以更容易地了解和探索你的工作。