Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: answer frequently asked questions #351

Merged
merged 5 commits into from
Apr 10, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,22 @@ Additional guides:
- Create a GitHub Personal Access Token. [[Link]](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line)
- Add authentication token to Travis CI. [[Link]](https://docs.travis-ci.com/user/environment-variables/#defining-variables-in-repository-settings)

## Custom Domain Issue with CNAME File

If you are using a custom domain with GitHub Pages, you might have encountered an issue where your custom domain configuration gets lost after deploying updates to your site. This problem occurs due to the deletion of the `CNAME` file in the root of the deployed directory during the git commit and push process performed by the `hexo-deployer-git` plugin.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think CNAME file was overwritten rather than deleted


GitHub requires the `CNAME` file to be present in your repository to associate your custom domain with your GitHub Pages site. When this file is missing, GitHub resets the custom domain setting, leading to the site being accessible only through the default `github.io` domain.

### Solution

To ensure your custom domain remains active with each deployment, you need to include the `CNAME` file in your blog's source files. Here's how you can do it:
stevenjoezhang marked this conversation as resolved.
Show resolved Hide resolved

1. **Create a `CNAME` File:** In the root of your blog's source directory, create a file named `CNAME`. Inside this file, enter your custom domain name. For example, if your custom domain is `example.com`, the content of the `CNAME` file should be:
stevenjoezhang marked this conversation as resolved.
Show resolved Hide resolved
```
example.com
```
2. **Deploy Your Site:** Use the `hexo-deployer-git` plugin to deploy your site as usual. Run `hexo g -d` command, the plugin will now include the `CNAME` file in the deployment, and your custom domain configuration will remain intact.

## How it works

`hexo-deployer-git` works by generating the site in `.deploy_git` and *force pushing* to the repo(es) in config.
Expand Down