Перейти к содержимому

Github io что это

  • автор:

Как использовать GitHub Pages?

GitHub — это сайт «социальной разработки». Он позволяет загружать репозитории кода для хранения в системе управления версиями Git. После загрузки вы можете сотрудничать с другими участниками для работы над общим проектом, а ещё это система с открытым исходным кодом по умолчанию: любой человек в мире может найти ваш код на GitHub, использовать его, учиться по нему и улучшать его. Вы тоже можете взаимодействовать с кодом других людей! В этой статье представлено базовое руководство по публикации контента с использованием функции gh-pages Github.

Публикация контента

GitHub — очень важное и полезное сообщество для участия, а Git/GitHub — очень популярная система управления версиями — большинство технологических компаний теперь использует её в своём рабочем процессе. У GitHub есть очень полезная функция GitHub Pages, которая позволяет публиковать живую демонстрацию кода в виде сайта в Интернете.

Базовая установка Github

  1. Прежде всего, установите Git на свой компьютер. Это базовое программное обеспечение для управления версиями, поверх которого работает GitHub.
  2. Затем зарегистрируйтесь на GitHub. Это просто.
  3. После того, как вы зарегистрировались, войдите в свою учётную запись на github.com с помощью своих имени пользователя и пароля.

Подготовка кода для загрузки

В репозитории на Github вы можете хранить любой код, который вам нравится, но для полноценного использования функции GitHub Pages ваш код должен быть структурирован как типичный веб-сайт, то есть, основной точкой входа должен быть HTML-файл с именем index.html .

Прежде чем двигаться дальше, вам необходимо инициализировать вашу папку (директорию) с кодом как репозиторий Git. Как это сделать:

    Направьте командную строку в вашу папку test-site (или папку с любым другим названием, содержащую ваш сайт). Для этого используйте команду cd (т.е. «change directory» — «поменяй директорию»). Вот что вы бы набрали, если бы разместили свой сайт в папке test-site на рабочем столе:

cd Desktop/test-site 
git init 
Дополнительно об интерфейсах командной строки

Лучший способ загрузить код в Github — использовать командную строку. Это окно, в котором вы вводите команды, чтобы делать такие вещи, как создавать файлы и запускать программы, вместо того чтобы кликать внутри пользовательского интерфейса. Оно будет выглядеть примерно так:

Примечание: вы также можете использовать графический пользовательский интерфейс Git для выполнения тех же задач, если вам неудобно работать с командной строкой.

Каждая операционная система поставляется с инструментом командной строки:

  • Windows: Командную строку (Command Prompt) можно вызвать, нажав клавишу Windows, набрав Command Prompt и выбрав её из появившегося списка. Обратите внимание, что в Windows свои собственные условные обозначения команд, отличные от Linux и OS X, поэтому приведённые ниже команды могут отличаться на вашем компьютере.
  • OS X: Терминал (Terminal) можно найти в Applications > Utilities.
  • Linux: Обычно терминал можно вызвать с помощью Ctrl + Alt + T. Если это не сработает, найдите Terminal в панели приложений или меню.

Сначала это может показаться немного пугающим, но не волнуйтесь — вы быстро разберётесь в основах. Вы говорите компьютеру что-то сделать в терминале, введя команду и нажав Enter, как показано выше.

Создание репозитория для вашего кода

  1. Затем вам нужно создать новый репозиторий для ваших файлов. Нажмите «Плюс» (+) в правом верхнем углу главной страницы GitHub и выберите «Новый репозиторий» (New Repository).
  2. На этой странице в поле «Имя репозитория» (Repository name) введите имя для своего репозитория, например my-repository.
  3. Также добавьте описание, чтобы уточнить, что будет содержать ваш репозиторий. Ваш экран должен выглядеть так:
  4. Нажмите «Создать репозиторий» (Create repository); откроется следующая страница:

Загрузка файлов на GitHub

  1. На текущей странице вас интересует раздел …or push an existing repository from the command line («. или загрузите существующий репозиторий с помощью командной строки»). В этом разделе вы должны увидеть две строки кода. Скопируйте всю первую строку, вставьте её в командную строку и нажмите Enter. Команда должна выглядеть примерно так:
git remote add origin https://github.com/chrisdavidmills/my-repository.git
git add --all git commit -m 'adding my files to my repository' 
git push -u origin main 

Больше информации о GitHub

Если вы хотите поменять что-то на своем тестовом сайте и загрузить результат на GitHub, вам просто нужно внести изменения в свои файлы, как и раньше. Затем вам потребуется ввести следующие команды (нажимая Enter после каждой), чтобы загрузить их на GitHub:

git add --all git commit -m 'another commit' git push

Вы можете написать более подходящее сообщение вместо another commit, чтобы уточнить, что именно вы только что изменили.

Мы едва коснулись Git. Чтобы узнать больше, начните с нашей статьи Git и GitHub.

Found a content problem with this page?

  • Edit the page on GitHub.
  • Report the content issue.
  • View the source on GitHub.

This page was last modified on 3 авг. 2023 г. by MDN contributors.

Your blueprint for a better internet.

Описание GitHub Pages

You can use GitHub Pages to host a website about yourself, your organization, or your project directly from a repository on GitHub.com.

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.»

About GitHub Pages

GitHub Pages is a static site hosting service that takes HTML, CSS, and JavaScript files straight from a repository on GitHub, optionally runs the files through a build process, and publishes a website. You can see examples of GitHub Pages sites in the GitHub Pages examples collection.

You can host your site on GitHub’s github.io domain or your own custom domain. For more information, see «Configuring a custom domain for your GitHub Pages site.»

You can create GitHub Pages sites that are publicly available on the internet. Organizations that use GitHub Enterprise Cloud can also publish sites privately by managing access control for the site. For more information, see «Changing the visibility of your GitHub Pages site» in the GitHub Enterprise Cloud documentation.

Organization owners can disable the publication of GitHub Pages sites from the organization’s repositories. For more information, see «Managing the publication of GitHub Pages sites for your organization.»

Types of GitHub Pages sites

There are three types of GitHub Pages sites: project, user, and organization. Project sites are connected to a specific project hosted on GitHub, such as a JavaScript library or a recipe collection. User and organization sites are connected to a specific account on GitHub.com.

To publish a user site, you must create a repository owned by your personal account that’s named .github.io . To publish an organization site, you must create a repository owned by an organization that’s named .github.io . Unless you’re using a custom domain, user and organization sites are available at http(s)://.github.io or http(s)://.github.io .

The source files for a project site are stored in the same repository as their project. Unless you’re using a custom domain, project sites are available at http(s)://.github.io/ or http(s)://.github.io/ .

For more information about how custom domains affect the URL for your site, see «About custom domains and GitHub Pages.»

You can only create one user or organization site for each account on GitHub. Project sites, whether owned by an organization or a personal account, are unlimited.

Publishing sources for GitHub Pages sites

Warning: GitHub Pages sites are publicly available on the internet, even if the repository for the site is private. If you have sensitive data in your site’s repository, you may want to remove the data before publishing. For more information, see «About repositories.»

You can publish your site when changes are pushed to a specific branch, or you can write a GitHub Actions workflow to publish your site.

If you do not need any control over the build process for your site, we recommend that you publish your site when changes are pushed to a specific branch. You can specify which branch and folder to use as your publishing source. The source branch can be any branch in your repository, and the source folder can either be the root of the repository ( / ) on the source branch or a /docs folder on the source branch. Whenever changes are pushed to the source branch, the changes in the source folder will be published to your GitHub Pages site.

If you want to use a build process other than Jekyll or you do not want a dedicated branch to hold your compiled static files, we recommend that you write a GitHub Actions workflow to publish your site. GitHub provides starter workflows for common publishing scenarios to help you write your workflow.

Static site generators

GitHub Pages publishes any static files that you push to your repository. You can create your own static files or use a static site generator to build your site for you. You can also customize your own build process locally or on another server.

If you use a custom build process or a static site generator other than Jekyll, you can write a GitHub Actions to build and publish your site. GitHub provides starter workflows for several static site generators. For more information, see «Configuring a publishing source for your GitHub Pages site.»

If you publish your site from a source branch, GitHub Pages will use Jekyll to build your site by default. If you want to use a static site generator other than Jekyll, we recommend that you write a GitHub Actions to build and publish your site instead. Otherwise, disable the Jekyll build process by creating an empty file called .nojekyll in the root of your publishing source, then follow your static site generator’s instructions to build your site locally.

GitHub Pages does not support server-side languages such as PHP, Ruby, or Python.

Limits on use of GitHub Pages

GitHub Pages sites created after June 15, 2016, and using github.io domains are served over HTTPS. If you created your site before June 15, 2016, you can enable HTTPS support for traffic to your site. For more information, see «Securing your GitHub Pages site with HTTPS.»

Prohibited uses

GitHub Pages is not intended for or allowed to be used as a free web-hosting service to run your online business, e-commerce site, or any other website that is primarily directed at either facilitating commercial transactions or providing commercial software as a service (SaaS). GitHub Pages sites shouldn’t be used for sensitive transactions like sending passwords or credit card numbers.

In addition, your use of GitHub Pages is subject to the GitHub Terms of Service, including the restrictions on get-rich-quick schemes, sexually obscene content, and violent or threatening content or activity.

Educational exercises

Using GitHub Pages to create a copy of an existing website as a learning exercise is not prohibited. However, in addition to complying with the GitHub Terms of Service, you must write the code yourself, the site must not collect any user data, and you must include a prominent disclaimer on the site indicating that the project is not associated with the original and was only created for educational purposes.

Usage limits

GitHub Pages sites are subject to the following usage limits:

  • GitHub Pages source repositories have a recommended limit of 1 GB. For more information, see «About large files on GitHub»
  • Published GitHub Pages sites may be no larger than 1 GB.
  • GitHub Pages deployments will timeout if they take longer than 10 minutes.
  • GitHub Pages sites have a soft bandwidth limit of 100 GB per month.
  • GitHub Pages sites have a soft limit of 10 builds per hour. This limit does not apply if you build and publish your site with a custom GitHub Actions workflow
  • In order to provide consistent quality of service for all GitHub Pages sites, rate limits may apply. These rate limits are not intended to interfere with legitimate uses of GitHub Pages. If your request triggers rate limiting, you will receive an appropriate response with an HTTP status code of 429 , along with an informative HTML body.

If your site exceeds these usage quotas, we may not be able to serve your site, or you may receive a polite email from GitHub Support suggesting strategies for reducing your site’s impact on our servers, including putting a third-party content distribution network (CDN) in front of your site, making use of other GitHub features such as releases, or moving to a different hosting service that might better fit your needs.

MIME types on GitHub Pages

A MIME type is a header that a server sends to a browser, providing information about the nature and format of the files the browser requested. GitHub Pages supports more than 750 MIME types across thousands of file extensions. The list of supported MIME types is generated from the mime-db project.

While you can’t specify custom MIME types on a per-file or per-repository basis, you can add or modify MIME types for use on GitHub Pages. For more information, see the mime-db contributing guidelines.

Data collection

When a GitHub Pages site is visited, the visitor’s IP address is logged and stored for security purposes, regardless of whether the visitor has signed into GitHub or not. For more information about GitHub’s security practices, see GitHub Privacy Statement.

Further reading

  • GitHub Pages on GitHub Skills
  • «Repositories»

GitHub Pages — что это и как использовать? Инструкция для новичков

Хотите узнать, что такое GitHub Pages и как их использовать? Мы написали инструкцию о том, что такое GitHub Pages, которую поймут даже новички. Видеоинструкция в конце.

GitHub Pages — что это и как использовать? Инструкция для новичков

В этой статье о GitHub Pages вы узнаете:

  1. Что такое GitHub Pages
  2. Как установить Git
  3. Как загрузить свой проект в GitHub Pages
  4. Как подключить свой домен к проекту

Что такое GitHub Pages

Git — это самая популярная система контроля версий в мире. GitHub Pages — это бесплатный хостинг для статических файлов.

Если вы создали сайт и оставили его у себя на ПК, то посмотреть его можно только с вашего ПК. Чтобы открыть его с другого устройства, нужно перенести файлы сайта на другое устройство. Чтобы не переносить эти файлы на все устройства в мире, их нужно загружать в облачные хранилища. Облачные хранилища для сайтов называются хостингами.

Что такое хостинг и зачем они нужны сайту

Стандартные хостинги платные. И они скрывают технические файлы сайта от всех, кроме владельцев. GItHub Pages — это бесплатный хостинг с открытой структурой. Это значит, что загрузить туда свои файлы может кто угодно. И любой пользователь может посмотреть все загруженные файлы проекта.

GitHub Pages сильно упрощают поиск работы для начинающих специалистов. Если вы освоите этот инструмент, то он выгодно выделит вас на фоне конкурентов. А HR—менеджеру будет проще и приятнее оценить ваши скиллы.

Хотите получить больше советов о том, как начинающему программисту найти работу? Прочитайте нашу статью.

Как установить Git

Что пользоваться GitHub Pages, нужно установить Git и зарегистрироваться в нем.

Как установить Git на Windows

Скачайте установочный файл с официального сайта и запустите его.

Как установить Git на Linux

Для Fedora — yum: $ yum install git-core
Для Debian (Ubuntu и другие) — apt-get: $ sudo apt-get install git

Для установки Git как бинарного пакета, используйте стандартный менеджер приложений.

Как установить Git на macOS

Скачайте и установите Homebrew Затем пропишите в терминале команду «brew install git».

Как загрузить свой проект в GitHub Pages

Сначала нужно зарегистрироваться на GitHub, если у вас еще нет аккаунта. Там стандартная форма регистрации. Затем создать новый репозиторий. Нажмите на «Your repositories», затем — «New».

Как создать новый репозиторий в GitHub Pages Как создать новый репозиторий в GitHub Pages

Заполните все пустые поля.
Название: заполняйте по форме «username.github.io». Username — название вашего аккаунта на GitHub. Отметьте галочкой пункт «Initialize this repository with a README». Нажмите на «Create repository».

Как создать новый репозиторий в гитхаб

Отлично, вы создали репозиторий. Теперь нужно загрузить в него файлы. Нажмите в правом верхнем углу на кнопку «Upload files». Перетащите в открывшееся окно файлы своего проекта и нажмите на кнопку «Commit changes». Отлично! Вы загрузили файлы.

Как загрузить сайт и другие файлы в GitHub Pages

Можете проверить работоспособность проекта. Для этого перейдите по ссылке: «https://github.com/username/github.io». Username — название вашего аккаунта.

Как подключить свой домен к проекту на GitHub Pages Как подключить свой домен к проекту на GitHub Pages

Теперь нужно зайти в редактор DNS-записей вашего провайдера, создать запись типа А и задать ей значение «192.30.252.153». Пункт к этому месту разный у всех провайдеров, но у них есть неплохие инструкции.

Хотите лучше разобраться в том, как работает GitHub? Обратитесь к специалисту!

Краткое руководство по GitHub Pages

Вы можете использовать GitHub Pages, чтобы продемонстрировать проекты с открытым кодом, вести блог или даже поделиться своим резюме. Это руководство поможет вам приступить к созданию вашего нового веб-сайта.

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.»

Introduction

GitHub Pages are public webpages hosted and published through GitHub. The quickest way to get up and running is by using the Jekyll Theme Chooser to load a pre-made theme. You can then modify your GitHub Pages’ content and style.

This guide will lead you through creating a user site at username.github.io .

Creating your website

  1. In the upper-right corner of any page, select

Screenshot of a GitHub dropdown menu showing options to create new items. The menu item

, then click New repository.

Screenshot of GitHub Pages settings in a repository. The repository name field contains the text

Enter username.github.io as the repository name. Replace username with your GitHub username. For example, if your username is octocat , the repository name should be octocat.github.io .

Settings. If you cannot see the «Settings» tab, select the

Screenshot of a repository header showing the tabs. The

dropdown menu, then click Settings.

Screenshot of Pages settings in a GitHub repository. A menu to select a branch for a publishing source, labeled

Pages.

  • Under «Build and deployment», under «Source», select Deploy from a branch.
  • Under «Build and deployment», under «Branch», use the branch dropdown menu and select a publishing source.

    Changing the title and description

    By default, the title of your site is username.github.io . You can change the title by editing the _config.yml file in your repository. You can also add a description for your site.

    1. Click the Code tab of your repository.
    2. In the file list, click _config.yml to open the file.
    3. Click

    theme: jekyll-theme-minimal title: Octocat's homepage description: Bookmark this to keep an eye on my project updates! 

    Next Steps

    For more information about how to add additional pages to your site, see «Adding content to your GitHub Pages site using Jekyll.»

    For more information about setting up a GitHub Pages site with Jekyll, see «About GitHub Pages and Jekyll.»

  • Добавить комментарий

    Ваш адрес email не будет опубликован. Обязательные поля помечены *