← Student Handout

CiTi · Computer Coding · Year One · Unit 3

Missed Class? WebDNA Catch-Up Review

Introduction to WebDNA: Date, Time & Reusable Includes

Quick Summary: the whole lesson in 5 steps

Read these five steps first. Each one has a “More” link that jumps to the full details further down.

  1. Square brackets mean WebDNA. HTML tags use angle brackets, like <p>. WebDNA tags use square brackets, like [date]. You type both into the same .html file. More →
  2. WebDNA only works on the server. The server runs your WebDNA tags before the page reaches your browser. So always test on your live URL, never from a file on your computer. More →
  3. Show the date and time. [date] and [time] print the date and time. Add format= to pick the style. Put &copy; [date format=%Y] in your footer so the year updates itself. More →
  4. Split your page into three include files. Make an includes folder with header.inc, nav.inc, and footer.inc. Each page pulls them in with [include]. Now you change something once, and it changes on every page. More →
  5. Use your full site path for every path. Every link, image, CSS file, and include starts with /citi/coding/2027/1/YOURINTS/mysite/. Then every page is just three include lines plus its own content. More →
When you are finished, your site will have An includes folder with header.inc, nav.inc, and footer.inc. All five pages use all three. Your footer shows a copyright year that updates itself.

1Square brackets mean WebDNA

You already know HTML tags. They use angle brackets: <p>, <div>, <h1>.

WebDNA is a second coding language. It is already installed on our web server. Its tags use square brackets: [date], [time], [include]. You type them right into your normal .html pages, mixed in with your HTML.

<p>Today is [date]</p> ↑ HTML ↑ WebDNA
Remember Angle brackets < > are HTML. Square brackets [ ] are WebDNA.

2WebDNA runs on the server

WebDNA is server-side code. That means the web server runs it. It happens before the page is sent to anyone’s browser. Here is what happens every time someone opens your page:

1. Your file on the server What you typed in Sublime. <p>Today is [date]</p>
→
2. Someone opens the page The server finds each WebDNA tag. It swaps the tag for its answer.
→
3. The browser gets Plain HTML. The tag is gone. <p>Today is 11/26/2026</p>

Box 3 is real. Our server ran that tag when you opened this page.

What this means for you

  • Always test on your live URL (http://dev.citicoders.org/...). If you open your file from your computer, or preview it from Sublime, no server runs it. Your tags will just show up as plain text, like [date].
  • View Source never shows WebDNA. Right-click your live page and choose View Page Source. Where you typed [date], you will see the real date. Your browser never sees the tag.
  • HTML and CSS are different. They are client-side. That means your browser reads them, so View Source shows them exactly as you wrote them.

3Date and time

By itself, [date] shows month/day/year. [time] shows the time on a 24-hour clock.

To pick your own style, add format= and some format codes. A format code is a % sign plus a letter. The server swaps each code for part of the date or time.

The green column below is live. Refresh this page and watch the time change.

What you typeWhat it shows right now
[date]11/26/2026
[time]13:30:59
[date format=%A, %B %d, %Y]Thursday, November 26, 2026
[date format=%m/%d/%y]11/26/26
[time format=%I:%M %p]01:30 PM
[date format=%A at %I:%M %p]Thursday at 01:30 PM
&copy; [date format=%Y] Jordan Diaz© 2026 Jordan Diaz

Format codes

The last column is live too. It shows what each code prints today.

CodeWhat it meansToday
%ADay of the weekThursday
%aDay of the week, shortThu
%BMonth nameNovember
%bMonth name, shortNov
%mMonth as a number11
%dDay of the month26
%YYear, 4 digits2026
%yYear, 2 digits26
%jDay number of the year330
%IHour, 12-hour clock01
%HHour, 24-hour clock13
%MMinutes30
%SSeconds59
%pAM or PMPM

Four rules to remember

  • Capital letters matter. %M means minutes, but %m means the month. %I (capital i) is the hour. Lowercase %i is not a code, so it just prints %i.
  • Anything that is not a code prints as you typed it. Commas, slashes, and words like “at” are fine inside the format.
  • Use one tag, not two. Date codes and time codes work in either tag. So [date format=%A at %I:%M %p] does the whole job in one tag. Each tag is extra work for the server.
  • It is the server’s clock. The time is Eastern time. It shows the moment the page was made, and it does not tick. Refresh the page to update it.
Why the copyright year matters Lots of real websites still say “© 2019” at the bottom. Someone forgot to update it. &copy; [date format=%Y] updates itself every January, forever.

4Includes: write it once, use it everywhere

Right now, every page of your site has its own copy of the header, the nav, and the footer. To add one nav link, you have to edit five files. If you miss one, your pages won’t match.

The [include] tag fixes that. You put the shared code in its own file. Then each page points to that file. When someone opens the page, the server pastes the file’s code into the page, right where the tag is. Change the file once, and every page changes.

New folder and files

mysite/ includes/ ← new folder header.inc ← top of every page nav.inc ← the navigation bar footer.inc ← bottom of every page css/ style.css images/ index.html about/ index.html contact/ index.html photos/ index.html author/ index.html

What goes in each file

Use your own site’s code. Cut each part out of your homepage and paste it into its file. Yours will look something like the examples below.

header.inc is the whole top of the page. That means everything from <!DOCTYPE html> down to the end of your header block. It includes the <head>, your CSS link, and the opening <body> tag.

includes/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 is just your navigation bar.

includes/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 is the whole bottom of the page. That means your footer block plus every closing tag after it. WebDNA tags still work inside an include, so your date and time go right here.

includes/footer.inc
<div class="footer"> <p>&copy; [date format=%Y] Jordan’s Lego Site</p> <p>Page made [date format=%A, %B %d at %I:%M %p]</p> </div> </div> </body> </html>
Opening tags in one file, closing tags in another header.inc opens <html>, <body>, and the container div. footer.inc closes them. That is normal. The server glues all the pieces into one complete page before anyone sees it. If your layout falls apart, check that every closing tag made it into footer.inc.

5Use the full site path everywhere

This is the most important rule in the whole lesson.

Your homepage is in the mysite folder. Your About page is one folder deeper, in mysite/about. But now both pages use the same include files.

A short path like css/style.css or images/logo.jpg works on the homepage. But on the About page, the browser looks for about/css/style.css and about/images/logo.jpg. Those don’t exist. So the page loses its colors and layout, pictures break, and links lead to a “404 Not Found” page.

The fix: start every path from the top of the website. That is your full site path. A path that starts with / works the same on every page, no matter which folder the page is in.

Your full site path /citi/coding/2027/1/YOURINTS/mysite/
Put your own initials where it says YOURINTS. Start every path with it:
  • 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 includes too: [include file=/citi/coding/2027/1/YOURINTS/mysite/includes/nav.inc]

Your whole page, after the switch

The top and bottom of your page now live in include files. So each page file shrinks down to just this:

index.html (and every other page)
[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]

The include lines use the full site path. So they are exactly the same on every page, whether the page is in mysite or mysite/about. Copy them once. Paste them everywhere. Only the bodycopy changes from page to page.

6Build it on your site

Work in CyberDuck and Sublime like always. After every step, check your live URL.

  1. Add the date to your footer first. On your homepage, add &copy; [date format=%Y] Your Name to the footer. Add one more date or time line that uses at least three format codes. Save, then check your live page.
  2. Make the folder. In CyberDuck, go into your mysite folder. Make a new folder named includes.
  3. Make the three files. Inside includes, use New File to make header.inc, nav.inc, and footer.inc. Open each one with Edit with Sublime Text.
  4. Move the top of the page. In your homepage, cut (don’t copy) everything from <!DOCTYPE html> down to the end of your header block. Paste it into header.inc.
  5. Move the nav and the bottom. Cut your nav into nav.inc. Cut your footer and every closing tag after it into footer.inc.
  6. Fix every path. In all three include files, change the CSS link, every image, and every nav link. Each one must start with /citi/coding/2027/1/YOURINTS/mysite/. Do the same for any images or links in your bodycopy.
  7. Add the include lines to your homepage. Put the header and nav includes above the bodycopy and the footer include below it, just like the example in Part 5. Save and check your live page. It should look exactly the same as before. That means it worked!
  8. Do the other four pages. On each page, delete everything except the bodycopy. Then paste in the same three include lines. You don’t change anything for pages in subfolders.
  9. Test everything. Open every page on your live site. Check that the styling shows, the images show, and every nav link works from every page. Then open View Source on one page. Make sure you can’t find any square-bracket tags.

7If something goes wrong

The page says “Error: template … not found”

Your include path has a mistake. The error shows the exact path the server tried. Read it letter by letter. Check your initials, the /1/, and the spelling of includes and the file name.

The homepage looks right, but other pages have no colors or layout

The CSS link in header.inc is a short path. Change it to start with /citi/coding/2027/1/YOURINTS/mysite/.

A picture works on one page but is broken on another

That image path is short (like images/logo.jpg). Give it the full site path.

A nav link works on one page but goes to “404 Not Found” on another

Same problem, same fix. That link in nav.inc needs the full site path.

I see [date] on the screen instead of the date

Either you are not on your live URL (you opened the file from your computer), or the tag is misspelled. WebDNA shows a misspelled tag exactly as you typed it. For example, [dat] shows up on the page as [dat].

My page shows two navs or two footers, or the layout is scrambled

You added the include but forgot to delete the old copy from that page. Or some closing tags got left behind on the page instead of moving into footer.inc.

The time looks wrong

Check your capital letters. If you typed %m instead of %M, you get the month where the minutes should be. Also remember: the time is Eastern time, and it does not tick. Refresh the page.

8Check yourself

Answer in your head first. Then click the question to check.

How can you tell a WebDNA tag from an HTML tag?

WebDNA tags use square brackets [ ]. HTML tags use angle brackets < >.

Why does View Source show the date but not the tag you typed?

WebDNA runs on the server. The server swaps the tag for the date before the page is sent. Your browser only ever gets the answer, never the tag.

What does [date format=%B %d, %Y] show?

Today it shows November 26, 2026.

Your logo shows on the homepage but is broken on the About page. Why?

Its path is short, like images/logo.jpg. From the About page, that points to about/images/logo.jpg, which doesn’t exist. Use the full site path: /citi/coding/2027/1/YOURINTS/mysite/images/logo.jpg.

Is the include line different on a page inside a subfolder?

No. It uses the full site path, so the same include line works on every page.

You want to add a new page to your nav. How many files do you edit now?

Just one: nav.inc. Every page gets the change by itself.

Am I done? Check before you tell your teacher

  • My includes folder has header.inc, nav.inc, and footer.inc.
  • All five pages use the same three include lines, with the full site path.
  • Every link, image, and CSS path starts with /citi/coding/2027/1/YOURINTS/mysite/.
  • My footer shows a copyright year using [date format=%Y].
  • My footer shows a date or time line that uses at least three format codes.
  • Every page has its styling and images, and every nav link works from every page.
  • View Source on my live page shows no square-bracket tags.
  • I filled in the student handout (Format Lab, My Footer, My Include Plan).