CiTi · Computer Coding · Year One · Unit 3
A lesson within “My First Website & Server-Side Management”
How do I manage large CSS projects? Can CSS be dynamic?
Today the question widens from CSS to the whole page: a page can be dynamic (built fresh by the server every time someone visits), and a large site stays manageable when shared pieces live in one file instead of being copied onto every page.
Demonstrates understanding in:
Reusable Code Assets Code Type via Syntax Website Planning & Construction Large Web Application PlanningHands-On:
#3 Build and deliver a website from a client brief
#7 Validate and debug my own work
Professional:
#7 Treat a mistake as data, not failure
#9 Document as you go
Symbolic notation: a format string like %A, %B %d is a pattern of placeholders that get replaced with values, the same idea as variables in an algebra expression. Decomposition: breaking a whole (a web page) into reusable parts, and reasoning about relative paths from different locations in a folder tree.
Maintainability: in industry, a site-wide change (a new menu item, a new phone number) must be made in one place, quickly and without missing a page. Reading an error message as information and fixing the cause, not the symptom.
Writing WebDNA [date] and [time] tags with custom format codes, adding an auto-updating copyright year, splitting a page into header.inc, nav.inc, and footer.inc, including them on every page, and using full site paths for every link, image, stylesheet, and include so shared files work at any folder depth.
Students will understand the difference between code the server runs before a page is sent and code the browser runs after it arrives: and will use WebDNA’s [date], [time], and [include] tags to give MySite a self-updating footer and to move its shared header, navigation, and footer into reusable include files.
[date] or [time] tag with a custom format that uses at least three format codes.header.inc, nav.inc, and footer.inc and include them on every page of MySite.Students refactor their own working site, then handle a surprise “client change request” that touches every page. Push further: have a classmate act as the client and send a change request in writing (new page, renamed link, new footer text); the developer replies with the live URL when it is done, moving toward “Realistic Industry Task.”
dev.citicoders.org, each with a top nav and bottom footer/citi/coding/2027/1/YOURINTS/mysite/ (with their initials). Every link, image, CSS, and include path uses it.WebDNA is a server-side language that is already installed on our server. Any .html page on dev.citicoders.org can contain WebDNA tags. Tags are written in square brackets, which is how students tell them apart from HTML tags in angle brackets.
Box 3 is not a screenshot: this server just ran that tag when you loaded this lesson.
| Server-side (WebDNA, PHP) | Client-side (HTML, CSS, JavaScript) | |
|---|---|---|
| Where it runs | On the web server, before the page is sent | In the visitor’s browser, after the page arrives |
| Whose clock | The server’s (ours is on Eastern time) | The visitor’s own device |
| View Source shows | Only the result (11/26/2026), never the tag | The actual code |
| Works from the desktop? | No. Opened as a local file, tags print as plain text | Yes |
| Changes after the page loads? | No. It is a snapshot; refresh to run it again | Yes (JavaScript can keep a clock ticking) |
The View Source test is the lesson’s key “aha”: students look for their [date] tag in View Source and cannot find it. The browser never sees WebDNA.
With no format, [date] prints month/day/year and [time] prints 24-hour time. Adding format= lets students build any layout they want from format codes.
The right column is live: the server ran each tag when this page loaded. Refresh to watch the time change.
| Tag | Output right now |
|---|---|
| [date] | 11/26/2026 |
| [time] | 13:30:56 |
| [date format=%A, %B %d, %Y] | Thursday, November 26, 2026 |
| [date format=%m/%d/%y] | 11/26/26 |
| [date format=%a %b %d] | Thu Nov 26 |
| [time format=%I:%M %p] | 01:30 PM |
| [date format=Day %j of %Y] | Day 330 of 2026 |
| [date format=%A at %I:%M %p] | Thursday at 01:30 PM |
| © [date format=%Y] Jordan Diaz | © 2026 Jordan Diaz |
| Code | Means |
|---|---|
| %A | Weekday, full (Monday) |
| %a | Weekday, short (Mon) |
| %B | Month, full (September) |
| %b | Month, short (Sep) |
| %m | Month number (01–12) |
| %d | Day of month (01–31) |
| %Y | Year, 4 digits (2026) |
| Code | Means |
|---|---|
| %y | Year, 2 digits (26) |
| %j | Day of the year (001–366) |
| %I | Hour, 12-hour clock (01–12) |
| %H | Hour, 24-hour clock (00–23) |
| %M | Minute (00–59) |
| %S | Second (00–59) |
| %p | AM or PM |
%M is minutes, %m is the month. %I (capital i) is the 12-hour clock; lowercase %i is not a code and prints as %i.[date format=%A at %I:%M %p] is better than two tags side by side: every tag is a separate job for the server.© [date format=%Y] never has to be edited again.MySite has five pages, and every one of them has its own copy of the header, nav, and footer. A single change (a new nav link, a new site name) means opening five files and hoping none is missed. [include] fixes that: the server pastes the contents of another file into the page, right where the tag sits, before the page is sent.
Students create the files in CyberDuck (New File, then Edit with Sublime), the same way they create pages. header.inc holds the whole top of the page, including the <head>, and footer.inc holds the whole bottom. Opening tags live in one file and their closing tags in another; the server joins the pieces into one complete page before it is sent.
Pages at different folder depths now share the exact same include files, so a short relative path in an include works on the homepage and breaks on every subfolder page. Anything with a file path uses the full site path from the web root, starting with /:
href="/citi/coding/2027/1/YOURINTS/mysite/about/"src="/citi/coding/2027/1/YOURINTS/mysite/images/logo.jpg"href="/citi/coding/2027/1/YOURINTS/mysite/css/style.css"[include file=/citi/coding/2027/1/YOURINTS/mysite/includes/nav.inc]Students replace YOURINTS with their initials. The payoff: the include lines are identical on every page, so they are copied once and pasted everywhere.
WebDNA tags inside an include still run, so the Day 1 footer moves in unchanged.
That is the entire file. Every page of MySite looks like this; only the bodycopy differs. The same three lines work in mysite/index.html and mysite/about/index.html.
Each of these has a one-line experiment for the “Break It” phase. Predict first, test, then undo. All results below were tested on our server.
When an include path is wrong, WebDNA prints the error right on the page, in the spot where the included block should be: Error: template 'includes/nav.inc' not found. The message shows the exact path it tried. With full site paths, the usual causes are typos: wrong initials, a missing /1/, or include instead of includes. A short path like includes/nav.inc works on the homepage but fails on every subfolder page, because it is looked up from the page’s own folder.
Try it: on about/index.html, change the nav include to the short path [include file=includes/nav.inc]. Read the error, then put the full path back.
Every include is pasted into pages at two different folder depths. A short path like href="about/", src="images/logo.jpg", or href="css/style.css" works from the homepage, but from about/index.html it points into about/: the link 404s, the image breaks, and the page loses all its styling. Before includes, each page had its own paths. Now one file serves every page, so every path starts from the top of the site with the full site path.
Try it: in header.inc, shorten the CSS link to href="css/style.css". Load the homepage (styled), then the About page (plain). Put the full path back.
If [date] appears on screen as the literal text, no server ran it. Two usual causes: the page was opened from the desktop or previewed from Sublime (a local file, no server), or the tag is misspelled. WebDNA prints tags it does not recognize exactly as typed, so [dat] shows up as [dat].
Try it: misspell the tag in the footer as [dat], upload, and view the live page.
[time format=%I:%m] looks right but puts the month where the minutes should be, so at 7:34 in September it shows 07:09. Lowercase %i is not a code at all and prints as %i. Nothing crashes; the output is quietly wrong, which is why testing the live page matters.
Try it: change %M to %m in the time format. Compare to the clock on the wall.
header.inc opens <html>, <body>, and the container div; footer.inc closes them. Students who move the footer div but leave </div></body></html> behind on the page (or on only some pages) get a scrambled layout or doubled closing tags. The fix is always the same: the page file should contain nothing but the three include lines and the bodycopy.
http://dev.citicoders.org/...). A file opened from the desktop cannot run WebDNA.nav.inc, it must be deleted from every page, or the page shows two navs.header.inc first.nav.inc. This is the payoff promised in the dropdown lesson: fix it once, fixed everywhere..inc extension, all three inside includes/ at the MySite root.[date] tag in View Source, the page is not being processed (wrong URL or local file).| Time | Phase | What happens |
|---|---|---|
| 5 min | Warm-Up / Hook | Show a real site whose footer says “© 2019.” Ask: “What does that tell you about this business? If this site had 300 pages, how would you keep that year current?” |
| 10 min | Direct Instruction: Server vs. Client | Walk the three-box flow. Live demo: add [date] to a page, upload, load it, then View Source. Students search for the tag and cannot find it. Fill in the server/client comparison on the handout. |
| 10 min | Format Codes | Project this lesson’s live output table and refresh it. Build one format together from the codes table. Students do the Format Lab on the handout: predict four outputs, then test them. |
| 15 min | Independent Practice | Students add to the MySite homepage footer: an auto-updating copyright year and one custom date/time line using at least three format codes. Upload and test live. |
| 10 min | Break It (Tricky Parts 3 & 4) | In pairs: misspell the tag, swap %M for %m, try %i. Predict, test, record, undo. |
| 5 min | Check-In | Quick share: best footer format in the room. Preview Day 2: “Your footer is on one page. Tomorrow it goes on all five, and you will only ever edit it once.” |
| Time | Phase | What happens |
|---|---|---|
| 5 min | Warm-Up | “How many files would you open to add one link to your nav right now?” Students count on the handout (usually five). Name the problem: copies drift apart. |
| 10 min | Direct Instruction | Demo on one page: create includes/footer.inc, cut the footer block into it, replace it with the include tag, upload, reload. Nothing looks different, and that is the point. Then show the whole-page pattern and the full-site-path rule for links, images, CSS, and includes. |
| 20 min | Guided Practice: Refactor MySite | Create the includes/ folder and three files. Refactor the homepage and test it live. Then refactor the other four pages. Change every link, image, and CSS path in the includes to the full site path. Test every page for styling, images, and working links. |
| 10 min | Break It (Tricky Parts 1 & 2) | Shorten one include path and read the error. Shorten the CSS link in header.inc and compare the homepage to the About page. Undo both. |
| 5 min | Client Change Request & Exit Ticket | Announce the change request (for example: add a sixth nav link and change the footer text). Students make it in nav.inc and footer.inc only and confirm it on every page. Record files edited: before vs. after. Exit ticket on the handout. |
Formative: Live MySite check: every page shows the current year and a custom date/time line; View Source shows no WebDNA tags; every page uses all three includes; every page keeps its styling and images, and every nav link works from every page. Handout Format Lab and Break It entries reviewed for reasoning, not for whether the prediction was right.
Exit ticket (completion-graded): “Explain why View Source on your page shows the date but not the [date] tag. Then name one change to your site that now takes one edit instead of five.”
Extension: Create includes/vars.inc containing [text]siteroot=/citi/coding/2027/1/YOURINTS/mysite/[/text], include it first on every page, and rewrite every path as href="[siteroot]about/". Now moving the whole site to a new folder takes one edit instead of dozens. (Preview of WebDNA variables.)