Publishing Websites Using GitHub Pages: Fundamentals and Best Practices Quiz

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.

  1. Website Deployment Branch Selection

    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?

    1. gh-pages
    2. main
    3. site-deploy
    4. web-root

    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.

  2. Supported File Types for Static Website Hosting

    When hosting a website using GitHub Pages, which types of files can be directly served and rendered to visitors?

    1. HTML, CSS, and JavaScript files
    2. PHP and Python scripts
    3. Server-generated dynamic content
    4. Compiled Java applications

    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.

  3. Repository Naming for Personal Hosted Sites

    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?

    1. username.github.io
    2. my-website
    3. main-site-page
    4. pages-project

    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.

  4. Enabling Custom Domains on Hosted Sites

    Which step is necessary to successfully link a custom domain to your website hosted on GitHub Pages?

    1. Update DNS settings to point to the site’s IP addresses
    2. Place a robots.txt file in your repository
    3. Install additional server-side software
    4. Configure shell scripts in the gh-pages branch

    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.

  5. Configuring Jekyll for Static Site Generation

    If you want to use Jekyll for static site generation with your hosted site, which configuration file determines important build settings?

    1. _config.yml
    2. index.html
    3. package.json
    4. jekyll-src.js

    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.