CiTi · Computer Coding · Year One · Unit 3
Introduction to WebDNA: Date, Time & Reusable Includes
Read these five steps first. Each one has a “More” link that jumps to the full details further down.
<p>. WebDNA tags use square brackets, like [date]. You type both into the same .html file.
More →
[date] and [time] print the date and time. Add format= to pick the style. Put © [date format=%Y] in your footer so the year updates itself.
More →
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 →
/citi/coding/2027/1/YOURINTS/mysite/. Then every page is just three include lines plus its own content.
More →
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.
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.
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:
Box 3 is real. Our server ran that tag when you opened this page.
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].[date], you will see the real date. Your browser never sees the tag.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 type | What 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 |
| © [date format=%Y] Jordan Diaz | © 2026 Jordan Diaz |
The last column is live too. It shows what each code prints today.
| Code | What it means | Today |
|---|---|---|
| %A | Day of the week | Thursday |
| %a | Day of the week, short | Thu |
| %B | Month name | November |
| %b | Month name, short | Nov |
| %m | Month as a number | 11 |
| %d | Day of the month | 26 |
| %Y | Year, 4 digits | 2026 |
| %y | Year, 2 digits | 26 |
| %j | Day number of the year | 330 |
| %I | Hour, 12-hour clock | 01 |
| %H | Hour, 24-hour clock | 13 |
| %M | Minutes | 30 |
| %S | Seconds | 59 |
| %p | AM or PM | PM |
%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.[date format=%A at %I:%M %p] does the whole job in one tag. Each tag is extra work for the server.© [date format=%Y] updates itself every January, forever.
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.
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.
nav.inc is just your navigation bar.
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.
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.
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.
/citi/coding/2027/1/YOURINTS/mysite/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]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)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.
Work in CyberDuck and Sublime like always. After every step, check your live URL.
© [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.mysite folder. Make a new folder named includes.includes, use New File to make header.inc, nav.inc, and footer.inc. Open each one with Edit with Sublime Text.<!DOCTYPE html> down to the end of your header block. Paste it into header.inc.nav.inc. Cut your footer and every closing tag after it into footer.inc./citi/coding/2027/1/YOURINTS/mysite/. Do the same for any images or links in your bodycopy.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 CSS link in header.inc is a short path. Change it to start with /citi/coding/2027/1/YOURINTS/mysite/.
That image path is short (like images/logo.jpg). Give it the full site path.
Same problem, same fix. That link in nav.inc needs the full site path.
[date] on the screen instead of the dateEither 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].
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.
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.
Answer in your head first. Then click the question to check.
WebDNA tags use square brackets [ ]. HTML tags use angle brackets < >.
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.
[date format=%B %d, %Y] show?Today it shows November 26, 2026.
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.
No. It uses the full site path, so the same include line works on every page.
Just one: nav.inc. Every page gets the change by itself.
includes folder has header.inc, nav.inc, and footer.inc./citi/coding/2027/1/YOURINTS/mysite/.[date format=%Y].