Ship it: a pull request and a live URL
How to fetch and submit this exercise
Once: install the tool and connect your account.
curl -fsSL https://gonomicon.com/install.sh | sh
gonomicon loginEach exercise: download it, edit the file named in the instructions, then submit.
gonomicon fetch fs-week-1/07-04-ship-it-pull-request-deploy
cd 07-04-ship-it-pull-request-deploy
gonomicon submitShip it: make the site safe to publish
Goal: fix a personal-site page so it still works when it is published in a subfolder like https://maya.github.io/portfolio/, then ship the real thing with a pull request and a live URL.
The problem
GitHub Pages serves a project site from a subfolder of the domain, not from the top. A link that starts with / means "the top of the whole domain", so it climbs right out of your repository's folder and lands on a 404.
Worked example, for a page published at https://sam.github.io/blog/:
href in the page | Where it really goes |
|---|---|
about.html | https://sam.github.io/blog/about.html (works) |
./about.html | https://sam.github.io/blog/about.html (works) |
/about.html | https://sam.github.io/about.html (404, escaped the folder) |
http://127.0.0.1:5500/about.html | your own computer, which nobody else can reach |
What you edit
Two files sit next to each other: ship_it_pull_request_deploy.html and ship_it_pull_request_deploy.css. On your real site they are index.html and styles.css, so a link to either name counts as a link to the page. The starter page has several things that would break or embarrass it once it is live. Find them.
Rules
- The page links its stylesheet once, in the
<head>, and the link still finds the CSS file when the site lives in a subfolder and when it lives at the top of a domain. - Every
href,srcand formactioneither stays inside the site or is anhttps:,mailto:ortel:address. Nothing may point atlocalhost,127.0.0.1, a private network address,file:or a folder on your own machine. - No
<base>tag. It would hard-code a folder name. - Every link to a
#sectionpoints at anidthat exists on the page. - The page has a real
<title>(not a placeholder), exactly one<h1>, alangon<html>, acharsetmeta tag and a viewport meta tag that does not lock zooming. - Keep the structure: one
<header>, one<nav>with at least three links, one<main>, one<footer>, and a heading inside every<section>. - In the CSS, write it mobile-first. On a narrow screen the nav links stack in a column using flexbox. From a
min-widthbreakpoint of your choosing (inremorem, between 20 and 80) they sit in a row. Use onlymin-widthqueries. - Links get a visible outline for keyboard users with
:focus-visible. Never turn an outline off. - CSS
url(...)values and@importmust not start with/orhttp:.
After the tests pass: ship your real site
This part is not graded, but it is the point of the project.
- Put your finished site on its own branch, push it, and open a pull request into the default branch. Read the diff, then merge.
- Publish with GitHub Pages or Netlify, then open the live address in a private window.
- Check that the tab title and the
<h1>match yourindex.html, and click every link.
What you'll practice
- Spotting paths that only work on your own machine
- Relative vs root-absolute paths
- Pull request and deploy habits
- Mobile-first flexbox and focus styles, again
Run it
gonomicon fetch fs-week-1/07-04-ship-it-pull-request-deploy
cd 07-04-ship-it-pull-request-deploy
gonomicon test
gonomicon submit
Hints
- Pretend your site lives at https://maya.github.io/portfolio/. A link that starts with / means the very top of maya.github.io, so it escapes your folder. Find every link that does that, and every address that only works on your own computer.
- Drop the leading slash on the stylesheet link and the Home link (or start them with ./ ). Use #about style links for sections on the same page. Anything with 127.0.0.1 or localhost has to go.
- Stylesheet href is just the css file name. Nav links: ./ then #about then #projects. Add lang="en" and a viewport meta tag, and give the page a real title. In the CSS: nav is a column by default, a row inside @media (min-width: 40rem), and a:focus-visible gets an outline.