Benjamin Lu

everyday is cool

Make a Local Link List with Python

A site with several hand-written pages can use a little help keeping its index up to date. This Python exercise takes the HTML filenames in a folder and prints a basic list. It’s written for modern Python so you can run it today while recreating the kind of housekeeping script … Continue reading →

Moving a Website to a New Host

A small site can look like a folder of files right up until you have to move it. Once it uses PHP and a database, the files are only part of what needs to travel. Try a practice move between two local environments. Copy the site files, export the database, … Continue reading →

A Small Blog Database

A folder of HTML pages is easy to browse until you want to show the most recent five entries automatically. A database can answer that question without you updating the index every time you add a page. In a local database, make a sample posts table with an integer id, … Continue reading →

Debugging a PHP Form

A form can look right in the browser and still send the wrong fields to the server. Start by tracing one value all the way from its input to the PHP code that receives it. On a local PHP site, make a form with method="post" and one input with name="display_name". … Continue reading →

Updating Part of a Page with JavaScript

A small example can explain the idea behind early Ajax interfaces. Click a button, request a text file, and place the answer into one part of the page. The rest of the page stays where it is. Give the page a button with ID load and a paragraph with ID … Continue reading →

The Light Left On

The house had settled for the night, the chairs pushed underneath the table. At the end of the hall a little light lay across the floorboards. Someone had left it on for whoever came home last. I think of that when I try to name the smallest way to say … Continue reading →

Writing a Small RSS Feed

An RSS feed lets a reader check a site for new entries without opening its homepage. A small feed can start with just a title, a site link, a description, and one item. <?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> <title>My Web Notes</title> <link>https://example.com/</link> <description>Notes about building websites</description> <item> <title>A new … Continue reading →

A Sidebar with CSS Floats

Before Flexbox and Grid, a common way to position a sidebar was to float it and give the article room beside it. Try this with an element named menu followed by an element named article. #menu { float: left; width: 10em; } #article { margin-left: 11em; } #footer { clear: … Continue reading →

The Pieces of a WordPress Theme

Once a site has more than a few entries, copying the same layout into every page stops being practical. A classic WordPress theme uses templates to place the content inside a common design. The idea is easiest to see by following one page through its templates. On a local test … Continue reading →

WordPress Pages and Posts

WordPress 1.5 introduced Pages alongside the chronological blog. That gave a small site two useful places to put things. A weekly update could go in a post, while an About page could have an address readers could return to whenever they needed it. You can try the distinction on a … Continue reading →