← All Lessons Student Handout →

CiTi · Computer Coding · Year One · Unit 3

Introduction to WebDNA: Date, Time & Reusable Includes

A lesson within “My First Website & Server-Side Management”

Program Computer Coding: Year 1
Unit 3: My First Website & Server-Side Management
Duration Two class periods (~55 min each)
Grouping Individual, with pair “Break It” checks
Project MySite

Essential Question

From the Year 1 curriculum map
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.

Curriculum Map Alignment

Verbatim from Yr 1 curriculum

Concept / Knowledge / Content: Web Tools

  • Compare and contrast client-side and server-side technologies
  • Identify issues related to website maintenance
  • Use templates and snippets to demonstrate efficient and consistent web site development

Skills / Tasks

Demonstrates understanding in:

Reusable Code Assets Code Type via Syntax Website Planning & Construction Large Web Application Planning
Projects & Activities touched: Compartmental Navigation (from the Unit 3 Client Managed Business Web Project list)

Program Connections

Skills & Portrait alignment

Program Skills: What I’m Building Toward

Hands-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

NYS Portrait of a Graduate

Academically Prepared Critical Thinker Creative Innovator

Guaranteed & Viable Curriculum Framework

3 Dimensions for this lesson

Integrated Academic Knowledge

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.

Employability Skills

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.

Technical Skills

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.

Learning Intention

“Unwrapped” from the standard

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.

Success Criteria

  • I can explain the difference between server-side and client-side code, and prove it using View Source.
  • I can write a [date] or [time] tag with a custom format that uses at least three format codes.
  • I can add a copyright year to my footer that updates itself every January.
  • I can move my header, nav, and footer into header.inc, nav.inc, and footer.inc and include them on every page of MySite.
  • I can fix an include path error and explain why every link, image, CSS, and include path must use the full site path.

Authenticity Continuum

Where this lesson sits today
Instruction & Skill Practice
Teacher-Designed Simulation
Realistic Industry Task
Authentic Audience / Client
Product, Service, Impact, Solution

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

Materials & Prep

  • Students’ MySite project with all five pages live on dev.citicoders.org, each with a top nav and bottom footer
  • Sublime Text, CyberDuck, and Chrome
  • Student Handout (y1-u3-l4-so)
  • Hook: a real website whose footer still shows an old copyright year (search a few local business sites; they are easy to find)
  • Teacher prep: confirm each student’s full site path for Day 2, for example /citi/coding/2027/1/YOURINTS/mysite/ (with their initials). Every link, image, CSS, and include path uses it.
  • Teacher prep: pick the Day 2 “client change request” in advance (suggestion: add a sixth nav link and change the footer text)

How WebDNA Works

Server-side vs. client-side

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.

1. The file on the server What the student typed in Sublime. <p>Today is [date]</p>
→
2. A visitor asks for the page The server runs every WebDNA tag first and swaps each one for its result.
→
3. What the browser receives Plain HTML. The tag is gone. <p>Today is 11/26/2026</p>

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 runsOn the web server, before the page is sentIn the visitor’s browser, after the page arrives
Whose clockThe server’s (ours is on Eastern time)The visitor’s own device
View Source showsOnly the result (11/26/2026), never the tagThe actual code
Works from the desktop?No. Opened as a local file, tags print as plain textYes
Changes after the page loads?No. It is a snapshot; refresh to run it againYes (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.

Day 1: Date & Time

Format codes, live output

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.

TagOutput 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
&copy; [date format=%Y] Jordan Diaz© 2026 Jordan Diaz

Format codes

CodeMeans
%AWeekday, full (Monday)
%aWeekday, short (Mon)
%BMonth, full (September)
%bMonth, short (Sep)
%mMonth number (01–12)
%dDay of month (01–31)
%YYear, 4 digits (2026)
CodeMeans
%yYear, 2 digits (26)
%jDay of the year (001–366)
%IHour, 12-hour clock (01–12)
%HHour, 24-hour clock (00–23)
%MMinute (00–59)
%SSecond (00–59)
%pAM or PM
  • Anything that is not a code prints as typed: commas, slashes, and whole words (“Day”, “at”) are allowed inside the format.
  • Case matters. %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 and time codes work in either tag. One tag like [date format=%A at %I:%M %p] is better than two tags side by side: every tag is a separate job for the server.
  • The copyright year is the practical payoff: &copy; [date format=%Y] never has to be edited again.

Day 2: Includes

Write it once, use it everywhere

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.

New folder and files

mysite/ includes/ ← new folder header.inc ← DOCTYPE, head, CSS link, opening body/container, header div nav.inc ← the nav div (dropdown and all) footer.inc ← footer div with date tags, then all closing tags css/ style.css images/ index.html about/ index.html contact/ index.html photos/ index.html author/ index.html

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.

The rule: every file path uses the full site path

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 /:

  • Links: href="/citi/coding/2027/1/YOURINTS/mysite/about/"
  • Images: src="/citi/coding/2027/1/YOURINTS/mysite/images/logo.jpg"
  • CSS: href="/citi/coding/2027/1/YOURINTS/mysite/css/style.css"
  • The include paths themselves: [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.

header.inc

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Jordan’s Lego Site</title> <link rel="stylesheet" href="/citi/coding/2027/1/YOURINTS/mysite/css/style.css"> </head> <body> <div class="container"> <div class="header"> <img src="/citi/coding/2027/1/YOURINTS/mysite/images/logo.jpg" alt="logo"> <h1>Jordan’s Lego Site</h1> </div>

nav.inc

<div class="nav"> <a href="/citi/coding/2027/1/YOURINTS/mysite/">Home</a> <a href="/citi/coding/2027/1/YOURINTS/mysite/about/">About</a> <a href="/citi/coding/2027/1/YOURINTS/mysite/contact/">Contact</a> <a href="/citi/coding/2027/1/YOURINTS/mysite/photos/">Photos</a> <a href="/citi/coding/2027/1/YOURINTS/mysite/author/">Author</a> </div>

footer.inc

<div class="footer"> <p>&copy; [date format=%Y] Jordan’s Lego Site</p> <p>Page built [date format=%A, %B %d at %I:%M %p]</p> </div> </div> </body> </html>

WebDNA tags inside an include still run, so the Day 1 footer moves in unchanged.

A whole page after the refactor

[include file=/citi/coding/2027/1/YOURINTS/mysite/includes/header.inc] [include file=/citi/coding/2027/1/YOURINTS/mysite/includes/nav.inc] <div class="bodycopy"> <div class="col-left"> left column (250 pixels) </div> <div class="col-right"> body copy (stretches to fit screen) </div> </div> [include file=/citi/coding/2027/1/YOURINTS/mysite/includes/footer.inc]

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.

The Tricky Parts

Break it on purpose

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.

1“Error: template not found”

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.

2Paths that work on one page and break on the next

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.

3The tag shows up as plain text

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.

4Case-sensitive format codes

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

5Opening tags in one file, closing tags in another

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.

Teacher Watch List

MySite integration
  • Always test through the live URL (http://dev.citicoders.org/...). A file opened from the desktop cannot run WebDNA.
  • Refactor one page first. Get the homepage fully working with all three includes before touching the other four pages.
  • Cut, don’t copy. After the nav moves into nav.inc, it must be deleted from every page, or the page shows two navs.
  • Full site path everywhere. The most common Day 2 bug is one short path left behind: a page with no styling or a broken image on subfolder pages only. Check the CSS link and images in header.inc first.
  • Last lesson’s dropdown now lives only in nav.inc. This is the payoff promised in the dropdown lesson: fix it once, fixed everywhere.
  • File names follow the class convention: lowercase, no spaces, .inc extension, all three inside includes/ at the MySite root.
  • Server time is Eastern time and the time is a snapshot of when the page was built. Students who expect a ticking clock can be told that is a client-side (JavaScript) job, coming later.
  • View Source check: if a student can find a [date] tag in View Source, the page is not being processed (wrong URL or local file).

Lesson Flow

Two periods, ~55 min each

Day 1: Server-side code and date/time

TimePhaseWhat 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.”

Day 2: Includes

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

Assessment

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