文章版本: Enterprise Server 2.17
Adding content to your GitHub Pages site using Jekyll
You can add a new page or post to your Jekyll site on GitHub Pages.
GitHub Pages 适用于具有 GitHub Free 和组织的 GitHub Free 的公共仓库,以及具有 GitHub Pro、GitHub Team、GitHub Enterprise Cloud 和 GitHub Enterprise Server 的公共和私有仓库。
People with write permissions for a repository can add content to a GitHub Pages site using Jekyll.
About content in Jekyll sites
Before you can add content to a Jekyll site on GitHub Pages, you must create a Jekyll site. For more information, see "Creating a GitHub Pages site with Jekyll."
The main types of content for Jekyll sites are pages and posts. A page is for standalone content that isn't associated with a specific date, such as an "About" page. The default Jekyll site contains a file called about.md
, which renders as a page on your site at YOUR-SITE-URL/about
. You can edit the contents of that file to personalize your "About" page, and you can use the "About" page as a template to create new pages. For more information, see "Pages" in the Jekyll documentation.
A post is a blog post. The default Jekyll site contains a directory named _posts
that contains a default post file. You can edit the contents of that post, and you can use the default post as a template to create new posts. For more information, see "Posts" in the Jekyll documentation.
Your theme includes default layouts, includes, and stylesheets that will automatically be applied to new pages and posts on your site, but you can override any of these defaults. 更多信息请参阅“关于 GitHub Pages 和 Jekyll”。
要为网站上的页面或帖子设置变量和元数据,例如标题和布局, 您可以将 YAML 前页添加到任意 Markdown 或 HTML 文件的顶部。 更多信息请参阅 Jekyll 文档中的“前页”。
当更改合并到站点的发布源时,对站点的更改将自动发布。 如果想先预览您的更改,可以在本地而不是 GitHub Enterprise 上进行更改。 然后在本地测试站点。 更多信息请参阅“使用 Jekyll 在本地测试 GitHub Pages 站点”。
Adding a new page to your site
-
在 GitHub Enterprise 上,导航到站点的仓库。
-
导航到站点的发布来源。 有关发布源的更多信息,请参阅“关于 GitHub Pages”。
-
In the root of your publishing source, create a new file for your page called PAGE-NAME.md, replacing PAGE-NAME with a meaningful filename for the page.
-
Add the following YAML frontmatter to the top of the file, replacing PAGE TITLE with the page's title and URL-PATH with a path you want for the page's URL. For example, if the base URL of your site is
https://octocat.github.io
and your URL-PATH is/about/contact/
, your page will be located athttps://octocat.github.io/about/contact
.layout: page title: "PAGE TITLE" permalink: /URL-PATH/
-
Below the frontmatter, add content for your page.
-
在页面底部,输入一条简短、有意义的提交消息,描述您对文件所作的更改。 您可以在提交消息中将提交归于多个作者。 更多信息请参阅“创建有多个合作作者的提交”。
-
在提交消息字段下面,确定是要将提交添加到当前分支还是新分支。 如果当前分支是
master
,则应选择为提交创建新分支,然后创建拉取请求。 更多信息请参阅“创建新的拉取请求”。 -
单击 Propose file change(提议文件更改)。
Adding a new post to your site
-
在 GitHub Enterprise 上,导航到站点的仓库。
-
导航到站点的发布来源。 有关发布源的更多信息,请参阅“关于 GitHub Pages”。
-
Navigate to the
_posts
directory. -
Create a new file called YYYY-MM-DD-NAME-OF-POST.md, replacing YYYY-MM-DD with the date of your post and NAME-OF-POST with the name of your post.
-
Add the following YAML frontmatter to the top of the file, replacing POST TITLE with the post's title, YYYY-MM-DD hh:mm:ss -0000 with the date and time for the post, and CATEGORY-1 and CATEGORY-2 with as many categories you want for your post.
layout: page title: "POST TITLE" date: YYYY-MM-DD hh:mm:ss -0000 categories: CATEGORY-1 CATEGORY-2
-
Below the frontmatter, add content for your post.
-
在页面底部,输入一条简短、有意义的提交消息,描述您对文件所作的更改。 您可以在提交消息中将提交归于多个作者。 更多信息请参阅“创建有多个合作作者的提交”。
-
在提交消息字段下面,确定是要将提交添加到当前分支还是新分支。 如果当前分支是
master
,则应选择为提交创建新分支,然后创建拉取请求。 更多信息请参阅“创建新的拉取请求”。 -
单击 Propose file change(提议文件更改)。
后续步骤
您可以将 Jekyll 主题添加到 GitHub Pages 站点,以自定义站点的外观。 For more information, see "Adding a theme to your GitHub Pages site using Jekyll."