个人网站的GitHub页面.如何部署文件夹 [英] GitHub pages for personal site. How to deploy a folder

查看:158
本文介绍了个人网站的GitHub页面.如何部署文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我在个人网站上使用GitHub页面,应该如何管理我的源文件?我有一个简单的设置可以正常工作.

If I am using GitHub pages for my personal site, how should manage my source files? I have a simple setup which works.

但是我知道我不能在GitHub页面上使用Jekyll插件.例如,如果我想使用Grunt优化我的图像,对于通常的应用程序/站点,它将在dist/public文件夹中生成输出,然后将其部署.但是我仍然想使用GitHub来管理我的源文件,该怎么办?

But I understand I can't using Jekyll plugins with GitHub pages. If I want to use Grunt for example to optimise my images, for a usual app/site, it will produce output in say a dist/public folder, which I will then deploy. But I want to still use GitHub to manage my source files, how should I do it?

推荐答案

取决于您使用的存储库类型,用户/组织( UO )站点或项目站点( P ),源和页面将在以下版本中进行版本控制:

Depending of repository kind your using, a User/Organization (UO) site or a Project site (P), sources and pages will be versionned in :

  • 用户/组织-来源:来源,页面:母版
  • 项目-来源:母版,页面: gh页
  • User/Organization - sources : sources, pages: master
  • Project - sources : master, pages: gh-pages

注意:pages分支是强制性的,但是source分支的名称可以更改.

Note: The pages branch is mandatory, but the sources branch name can be changed.

  • 初始化一个空的github存储库: UO github.com/userName.github.io 初始化 github.com/repositoryName > P

在本地初始化本地存储库:

Locally, initialize your local repository :

  • 转到源文件夹cd /home/username/www/yoursite或所需的任何内容
  • git init
  • git remote add origin git@github.com:userName/userName.github.io.git( UO )或git remote add origin git@github.com:userName/repositoryName.git( P )
  • git checkout -b sources( UO )或git checkout master( P )
  • 在您的.gitignore中添加您的dist/public.由于您当前在master上,我们将忽略它在另一个分支中的版本
  • git add -A
  • git commit -m基础源".您现在已经提交了您的资源.
  • git push origin sources( UO )或git push origin master( P )将您的来源推送到适当的分支中
  • cd dist/public
  • touch .nojekyll,此文件告诉gh-pages无需构建Jekyll网站
  • git init
  • git remote add origin git@github.com:userName/userName.github.io.git( UO )或git remote add origin git@github.com:userName/repositoryName.git( P )
  • git checkout master( UO )或git checkout -b gh-pages( P )将此存储库放在适当的分支上
  • 您的grunt任务在这里
  • git add -A
  • git commit -m "first build"提交您的站点代码
  • git push origin master( UO )或git push origin gh-pages( P )
  • Go to source folder cd /home/username/www/yoursite or anything you want
  • git init
  • git remote add origin git@github.com:userName/userName.github.io.git (UO) or git remote add origin git@github.com:userName/repositoryName.git (P)
  • git checkout -b sources (UO) or git checkout master (P)
  • in your .gitignore add your dist/public. As you are currently on master we will ignore it an version it in an other branch
  • git add -A
  • git commit -m "base sources". You now have committed your sources.
  • git push origin sources (UO) or git push origin master (P) push your sources in the appropriate branch
  • cd dist/public
  • touch .nojekyll, this file tells gh-pages that there is no need to build a Jekyll site
  • git init
  • git remote add origin git@github.com:userName/userName.github.io.git (UO) or git remote add origin git@github.com:userName/repositoryName.git (P)
  • git checkout master (UO) or git checkout -b gh-pages (P) put this repository on the appropriate branch
  • your grunt task here
  • git add -A
  • git commit -m "first build" commit your site code
  • git push origin master (UO) or git push origin gh-pages (P)

您现在已经在两个不同的分支中推送了代码和页面.现在将根据您的位置来推送它们:

You now have pushed your code and pages in two different branches. They will now be pushed depending on where you are :

  • cd yourWorkingDirestory
  • git add -A
  • git commit -m "your commit message"
  • git push origin sources( UO )或git push origin master( P )
  • cd yourWorkingDirestory
  • git add -A
  • git commit -m "your commit message"
  • git push origin sources (UO) or git push origin master (P)
  • cd yourWorkingDirestory/dist/public
  • git add -A
  • git commit -m "your commit message"
  • git push origin master( UO )或git push origin gh-pages( P )
  • cd yourWorkingDirestory/dist/public
  • git add -A
  • git commit -m "your commit message"
  • git push origin master (UO) or git push origin gh-pages (P)

这篇关于个人网站的GitHub页面.如何部署文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆