Гитхаб ошибка 404

I had this exact problem with typedocs. The README.md worked but none of the actual docs generated by my doc strings displayed, I just got a 404 Github Pages screen.

To fix this, just place a empty file in your /docs directory (or wherever you generate your docs) & call it .nojekyll

To confirm, your file structure should now look like:

./docs/.nojekyll  # plus all your generated docs

Push this up to your remote Github repo and your links etc should work now.

Also make sure you have selected in your Github settings:

Settings -> Github Pages -> Source -> master brach /docs folder

Depending on your doc framework, you probably have to recreate this file each time you update your docs, this is an example of using typedocs & creating the .nojekyll file each time in a package.json file:

# package.json

      "scripts": {
        "typedoc": "typedoc --out docs src && touch docs/.nojekyll"
      },

Это руководство поможет вам устранить распространенные причины, по которым может появиться ошибка 404.

GitHub Pages is available in public repositories with GitHub Free and GitHub Free for organizations, and in public and private repositories with GitHub Pro, GitHub Team, GitHub Enterprise Cloud, and GitHub Enterprise Server. For more information, see «GitHub’s plans.»

Troubleshooting 404 errors

In this guide you’ll find common reasons you may be seeing a 404 error while building your GitHub Pages site.

  • GitHub’s Status page
  • DNS setup
  • Browser cache
  • index.html file
  • Directory contents
  • Custom domain
  • Repository

GitHub’s Status page

If you see a 404 error while building a GitHub Pages site, first check GitHub’s Status page for any active incidents.

DNS setup

Make sure GitHub’s DNS records are set up correctly with your DNS provider. For more information, see «Managing a custom domain for your GitHub Pages site.»

Browser cache

If your GitHub Pages site is private and you see a 404 error, you may need to clear your browser’s cache. For more information on clearing your cache, see your browser’s documentation.

index.html file

GitHub Pages will look for an index.html file as the entry file for your site.

  • Make sure you have an index.html file in the repository for your site on GitHub. For more information, see «Creating a GitHub Pages site.»

  • The entry file must be at the top level of your chosen publishing source. For example, if your publishing source is the /docs directory on the main branch, your entry file must be located in the /docs directory on a branch called main.

    If your publishing source is a branch and directory, the entry file must be at the top level of the source directory on the source branch. For example, if your publishing source is the /docs directory on the main branch, your entry file must be located in the /docs directory on a branch called main.

    If your publishing source is a GitHub Actions workflow, the artifact that you deploy must include the entry file at the top level of the artifact. Instead of adding the entry file to your repository, you may choose to have your GitHub Actions workflow generate your entry file when the workflow runs.

  • The name of the index.html file is case sensitive. For example, Index.html will not work.

  • The name of the file should be index.html, not index.HTML or any other variation.

Directory contents

Check that your directory contents are in the root directory.

Custom domain

If you’re using a custom domain, make sure it’s set up correctly. For more information, see «About custom domains and GitHub Pages.»

  • The CNAME record should always point to <USER>.github.io or <ORGANIZATION>.github.io, excluding the repository name. For more information about how to create the correct record, see your DNS provider’s documentation.
  • If you are able to access your landing page, but encounter broken links throughout, it is likely because you either didn’t have a custom domain name before or are reverting back from having a custom domain name. In such cases, changing the routing path does not initiate a rebuild of the page. The recommended solution is to ensure that your site rebuilds automatically when adding or removing a custom domain name. This may involve configuring a commit author and modifying the custom domain name settings.

Repository

Check whether your repository meets the following requirements.

  • The branch you are using to publish your site must be the main or default branch.
  • The repository must have a commit pushed to it by someone with admin permissions for the repository, such as the repository owner.
  • Switching the repository’s visibility from public to private or vice versa will change the URL of your GitHub Pages site, which will result in broken links until the site is rebuilt.

If you are still receiving a 404 error, start a GitHub Community discussion in the Pages category.

I had this exact problem with typedocs. The README.md worked but none of the actual docs generated by my doc strings displayed, I just got a 404 Github Pages screen.

To fix this, just place a empty file in your /docs directory (or wherever you generate your docs) & call it .nojekyll

To confirm, your file structure should now look like:

./docs/.nojekyll  # plus all your generated docs

Push this up to your remote Github repo and your links etc should work now.

Also make sure you have selected in your Github settings:

Settings -> Github Pages -> Source -> master brach /docs folder

Depending on your doc framework, you probably have to recreate this file each time you update your docs, this is an example of using typedocs & creating the .nojekyll file each time in a package.json file:

# package.json

      "scripts": {
        "typedoc": "typedoc --out docs src && touch docs/.nojekyll"
      },

Если вы получили 404 Page not Found

Когда вы публикуете свой сайт на GitHub Pages, то GitHub даёт вам ссылку вида https://USERNAME.github.io/REPONAME, где USERNAME — ваш ник на GitHub, а REPONAME — название репозитория на GitHub, куда вы залили свой сайт.

Это ссылка только на сам репозиторий, в котором много файлов и GitHub не знает, какой из них нужно показать. Если бы в репозитории в корне лежал файл index.html, то GitHub бы догадался и этот файл открылся бы по ссылке https://USERNAME.github.io/REPONAME. Но если ваш index.html где-то спрятан, например, в папке pages/ — Гитхабу нужно явно показать, где искать нужный .html файл: https://USERNAME.github.io/REPONAME/pages/index.html

index.html — это особое название для файла и GitHub Pages догадается показать его, даже если в ссылке его не указать: https://USERNAME.github.io/REPONAME/pages.

GitHub обновляет сайт раз в 10 минут

Ответ об этом на SO. Если вы допустили какую-то ошибку и что-то поправили в файлах — придётся ждать целых 10 минут, чтобы подгрузилась исправленная версия 😦

После каждого изменения в коде сайта ждите минимум 10 минут, прежде чем заходить на сайт и тестировать эти изменения. А лучше всего всё делать на своём компьютере и заливать на GitHub Pages уже готовую версию.

Если ссылки на сайте не открываются

Вам поможет статья про относительный адрес. Делайте ссылки относительными, а не абсолютными, чтобы сайту было всё равно где он хостится: хоть на 127.0.0.1, хоть на GitHub Pages. Если всё равно ошибка — и не получается написать правильный путь до файла — вот статья как это чинить


Попробуйте бесплатные уроки по Python

Получите крутое код-ревью от практикующих программистов с разбором ошибок и рекомендациями, на что обратить внимание — бесплатно.

Переходите на страницу учебных модулей «Девмана» и выбирайте тему.

Набор на курс до мидла

Набор на курс до мидла

HTTP 404 error is a common issue encountered by users when trying to access a Github Pages site. This error occurs when the server can’t find the requested page or resource, meaning the URL you entered may be incorrect, the page has been moved or deleted, or the URL has been misspelled. In this case, it’s essential to know how to fix the error to access the content on the Github Pages site.

Method 1: Check the URL

If you are encountering HTTP 404 error on your Github Pages, it means that the page you are trying to access does not exist. The most common cause of this error is when the URL is incorrect or misspelled. In this tutorial, we will show you how to fix HTTP 404 error on Github Pages by checking the URL.

Steps:

  1. Check the URL for any typos or errors.
<!DOCTYPE html>
<html>
<head>
    <title>My Github Page</title>
</head>
<body>
    <h1>Welcome to my Github Page</h1>
</body>
</html>
  1. Make sure that the file name and extension are correct. For example, if you are trying to access a file named «index.html», make sure that the file name is spelled correctly and that it has the «.html» extension.

  2. Check the file path. If the file is in a subdirectory, make sure that the path is correct. For example, if the file is in a subdirectory named «pages», the URL should be «https://yourusername.github.io/pages/filename.html».

  3. If you have recently made changes to your Github Pages, make sure that the changes have been committed and pushed to the repository.

  4. If you are still encountering HTTP 404 error, try clearing your browser cache and cookies. Sometimes, cached files can cause issues with Github Pages.

  5. If none of the above steps work, try rebuilding your Github Pages. Sometimes, Github Pages can have issues that require a rebuild to fix.

By following these steps, you should be able to fix HTTP 404 error on Github Pages by checking the URL.

Method 2: Ensure the Repository is Public

To fix the HTTP 404 error on Github Pages, you can try ensuring that the repository is public. Here are the steps to do this:

  1. Go to your repository on Github and click on «Settings».
  2. Scroll down to the «GitHub Pages» section.
  3. Under «Source», select «master branch» or «main branch».
  4. Make sure that the repository is set to «Public».
  5. Click on «Save».
name: Github Pages

on:
  push:
    branches:
      - master

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Build and deploy
        uses: JamesIves/github-pages-deploy-action@4.1.1
        with:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          BRANCH: gh-pages
          FOLDER: .

In the above example, we have a YAML configuration file for Github Pages. Note that we have specified the branch to be «master» under the «on» section. Also, we are using the «github-pages-deploy-action» to build and deploy our pages. Make sure to replace the «GITHUB_TOKEN» with your own token.

<!-- Example HTML code for Github Pages -->
<!DOCTYPE html>
<html>
<head>
    <title>My Github Page</title>
</head>
<body>
    <h1>Hello World!</h1>
    <p>Welcome to my Github Page.</p>
</body>
</html>

In the above example, we have some basic HTML code for our Github Pages. Note that the title is set to «My Github Page» and we have a heading and a paragraph.

That’s it! By ensuring that the repository is public, you should now be able to access your Github Pages without encountering the HTTP 404 error.

Method 3: Verify the Branch Settings

If you are encountering the HTTP 404 error on your Github Pages, one of the possible solutions is to verify your branch settings. Here are the steps to do it:

  1. Go to your Github repository and click on «Settings».
  2. Scroll down to the «Github Pages» section.
  3. In the «Source» section, select the branch that contains your website files. By default, it should be the «main» branch.
  4. Make sure that the folder path is correct. It should be the root directory if your website files are located in the main branch.
  5. Click on «Save».

Here is an example code for verifying the branch settings:



- Branch: main
- Folder: /

In this example, the website files are located in the root directory of the «main» branch.

By verifying the branch settings, you ensure that Github Pages is looking at the correct branch and folder path for your website files. This can help resolve the HTTP 404 error.

Note that it may take a few minutes for the changes to take effect. If the error persists, you may need to check other possible causes such as file names and paths, permissions, or DNS settings.

Method 4: Confirm the Project Pages Source

Here are the steps to fix HTTP 404 on Github Pages using «Confirm the Project Pages Source»:

  1. Go to your repository on Github and click on the «Settings» tab.
  2. Scroll down to the «Github Pages» section and make sure that the source is set to «master branch» or the branch where your code resides.
  3. If the source is already set correctly, try refreshing the page or waiting a few minutes for the changes to take effect.
  4. If the issue persists, check your repository’s code to ensure that the file path and name are correct.
  5. Make sure that the file is in the correct directory and that it is spelled correctly.
  6. Double-check that the file extension is correct (e.g. «.html» for HTML files).
  7. If all of the above steps fail, you can try using the «Confirm the Project Pages Source» feature. This feature allows you to confirm that your Github Pages source is correct by creating a file called «.nojekyll» in the root directory of your repository.

Here is an example of how to use «Confirm the Project Pages Source» with code:

  1. Open your terminal or command prompt and navigate to your local repository.

  2. Create a new file in the root directory called «.nojekyll» by typing the following command:

  3. Add and commit the new file to your repository by typing the following commands:

    git add .nojekyll
    git commit -m "Added .nojekyll file to confirm Github Pages source"
  4. Push the changes to your Github repository by typing the following command:

  5. Wait a few minutes for the changes to take effect, then try accessing your Github Pages site again. The HTTP 404 error should be resolved.

That’s it! By following these steps, you should be able to fix HTTP 404 errors on Github Pages using «Confirm the Project Pages Source».

Method 5: Redeploy the Github Pages Site

To fix the HTTP 404 error on Github Pages, you can try redeploying the Github Pages site. Here are the steps to do it:

  1. Open your Github repository and go to the «Settings» tab.
  2. Scroll down to the «Github Pages» section and check the source of your Github Pages site. It should be set to «main» or «master» branch.
  3. If the source is correct, go to the «Actions» tab and select «Deploy Github Pages» workflow.
  4. Click on the «Run Workflow» button and wait for the deployment process to finish.
  5. Once the deployment is completed, go back to the «Settings» tab and scroll down to the «Github Pages» section. You should see a green message that says «Your site is published at [your Github Pages URL]».

Here is an example code for the Github Actions workflow file:

name: Deploy Github Pages

on:
  push:
    branches:
      - main # Replace with your branch name

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Build and deploy site
        uses: JamesIves/github-pages-deploy-action@4.1.2
        with:
          branch: main # Replace with your branch name
          folder: _site # Replace with your build output folder

In this example, we use the «github-pages-deploy-action» to build and deploy the Github Pages site. The «branch» parameter specifies the branch to deploy, and the «folder» parameter specifies the build output folder.

Hope this helps you fix the HTTP 404 error on Github Pages!

Понравилась статья? Поделить с друзьями:
  • Гипотеза старения гипотеза ошибок
  • Гитлаб ошибка 502
  • Гильза воздушного фильтра ошибка volvo fh
  • Гипсокартон ошибки и правила монтажа
  • Гистология вероятность ошибки