github 项目子目录重定向到自定义域

github project sub-directory redirects to custom domain

我这里有一个 github 项目页面: lwymarie.github.io/QPQ_Web/Quasars_Probing_Quasars/Welcome.html

项目名为 QPQ_Web。其中有一个index.html文件,它指向子目录Quasars_Probing_Quasars中的一个Welcome.html文件,所有其他html文件也存储在该目录中。

我想用 www.qpqsurvey.org 替换 URL 的整个 lwymarie.github.io/QPQ_Web/Quasars_Probing_Quasars/ 部分。即我想跳过 URL 中的 Quasars_Probing_Quasars 子目录。请参阅当前 www.qpqsurvey.org 站点以了解我的意思。

是否可以为此目的设置永久链接而不重组我的文件?谢谢。

似乎与这个问题有关:

(1) 按照以下说明将您的子目录设为 GitHub 根目录,然后 (2) 重定向 http://www.qpqsurvey.org to gh-pages as you ordinarily would according to GitHub's custom domain instructions: https://help.github.com/articles/using-a-custom-domain-with-github-pages/

复制@CodeWizard 的答案,我的前半部分又引用了 https://gist.github.com/cobyism/4730490

正在将子文件夹部署到 GitHub 页面

有时您希望 master 分支上的子目录成为存储库 gh-pages 分支的根目录。这对于使用 Yeoman 开发的站点之类的东西很有用,或者如果您在 master 分支中包含一个 Jekyll 站点以及其余代码。

为了这个例子,我们假设包含您网站的子文件夹名为 dist.

第 1 步

从项目的 .gitignore 文件中删除 dist 目录(Yeoman 默认忽略它)。

第 2 步

确保 git 了解您的子树(您网站的子文件夹)。

git add dist && git commit -m "Initial dist subtree commit"

第 3 步

使用子树推送将其发送到 GitHub 上的 gh-pages 分支。

git subtree push --prefix dist origin gh-pages

繁荣。如果您的文件夹不叫 dist,那么您需要在上面的每个命令中更改它。


如果您定期这样做,您还可以 create a script 在您的路径中的某处包含以下内容:

#!/bin/sh
if [ -z "" ]
then
  echo "Which folder do you want to deploy to GitHub Pages?"
  exit 1
fi
git subtree push --prefix  origin gh-pages

它可以让您键入如下命令:

git gh-deploy path/to/your/site