Explore key concepts and workflows for hosting static websites with GitHub Pages, including branching strategies, configuration, supported file types, custom domain setup, and deployment methods. Gauge your understanding of essential practices for managing and publishing web content in a collaborative development environment.
Which branch is typically used for deploying a website using GitHub Pages when hosting a project site, and why is this branch preferred in this context?
Explanation: The 'gh-pages' branch is commonly used for publishing project sites because GitHub Pages is configured to serve content from this branch by default for project repositories. The 'main' branch typically contains source code, not the deployment-ready site. The 'site-deploy' and 'web-root' branch names are incorrect or not standard, so they will not be automatically recognized for deployment. Configuring the correct branch ensures proper web content delivery.
When hosting a website using GitHub Pages, which types of files can be directly served and rendered to visitors?
Explanation: GitHub Pages supports serving static files such as HTML, CSS, and JavaScript, making it ideal for static website hosting. PHP and Python scripts or compiled applications are not executed and cannot provide dynamic behavior. Server-generated or dynamic content is not supported, as there are no backend processes running. Static file support ensures security and predictable performance.
To publish a personal website using GitHub Pages, what naming format should you use for your repository to enable automatic deployment to the root domain?
Explanation: The required format for a personal website repository is 'username.github.io' to associate the deployment with your user account and publish at the root domain. Naming the repository 'my-website', 'main-site-page', or 'pages-project' will not trigger automatic deployment to the main site address. Correct naming ensures your site is accessible at the default personal domain.
Which step is necessary to successfully link a custom domain to your website hosted on GitHub Pages?
Explanation: To use a custom domain, you must update your DNS records to direct traffic to the correct IP addresses for the hosted site. Adding a robots.txt file only affects search engine crawling and not domain linking. Installing server-side software and adding shell scripts are unnecessary and unsupported, as the platform does not run backend code. Proper DNS configuration ensures your domain directs visitors to your site.
If you want to use Jekyll for static site generation with your hosted site, which configuration file determines important build settings?
Explanation: The '_config.yml' file defines Jekyll settings such as theme, plugins, and build options. 'index.html' is a web page file, not a configuration file. 'package.json' is used by different build tools and has no effect on Jekyll unless you’re integrating extra tools. 'jekyll-src.js' is not a recognized configuration file and will not affect the site's Jekyll build. Using the correct file ensures your site is built as intended.