Local web page programming on a Mac

Click For Summary

Discussion Overview

The discussion focuses on programming local web pages on a Mac, specifically addressing how to create and save HTML files using the Mac's built-in text editor, TextEdit. Participants explore methods to ensure the files are recognized as HTML by web browsers and share additional tips related to web server setup on macOS.

Discussion Character

  • Technical explanation
  • Conceptual clarification
  • Homework-related

Main Points Raised

  • One participant describes their experience transitioning from Windows to Mac and expresses difficulty in saving HTML files correctly using TextEdit.
  • Another participant suggests saving the file as a .txt file and then changing the extension to .html, while also recommending the use of Emacs for editing.
  • A participant notes the limitation of not being able to select .txt in the Save interface and suggests using the "Make Plain Text" option in the Format menu to convert the file.
  • Further advice is given on setting TextEdit to default to plain text format for future documents.
  • One participant shares information about the pre-installed Apache web server on macOS and provides instructions on how to start it and create a local web directory for testing HTML files.
  • Another participant mentions their personal workflow for maintaining a website using local copies on their Mac, emphasizing the importance of backups.

Areas of Agreement / Disagreement

Participants generally agree on the methods to save HTML files using TextEdit and the utility of converting to plain text. However, there is no consensus on the necessity of using additional software like Emacs, as some participants prefer to stick with default applications.

Contextual Notes

Some limitations include the dependency on specific macOS versions for certain features and the need for administrative permissions to install additional software. The discussion does not resolve the best practices for web development on a Mac, as various approaches are presented without definitive conclusions.

tony873004
Science Advisor
Gold Member
Messages
1,753
Reaction score
143
I'm used to Windows. I open notepad or wordpad and type
<html>
Hello world
</html>
and save it as a .txt file with an .html extension.

How do I do this on a Mac?
It seems the free included text editor is called textEdit.
But it does not allow me to save as a simple txt file with an .html extension.
I can choose .html as the file type, but it doesn't execute my code as a web page. It just echos my code back to me when I open the file in a browser.
 
Technology news on Phys.org
You can save it as a txt file, then change the extension.

I suggest you install and use Emacs.
 
DrClaude said:
You can save it as a txt file, then change the extension.

I suggest you install and use Emacs.
The problem is that .txt is not in the dropdown list of file types on the Save interface.
I'd have to get the IT guys to install software since this is my work computer. So I'm looking for a simple way to do it with the Mac's default programs.
 
tony873004 said:
The problem is that .txt is not in the dropdown list of file types on the Save interface.
In the Format menu, choose "Make Plain Text". It converts to plain text and will save automatically with an extension .txt.
 
Thanks! That worked.
 
DrClaude said:
In the Format menu, choose "Make Plain Text".

To make plain text (instead of rich text) the default, choose TextEdit --> Preferences --> New Document, and click the "Plain Text" button.

By the way [for the OP] your Mac already has Apache installed, so you can see how a web server delivers your pages. If you're using Mac OS 10.8 or later, launch the Terminal application (it's in Applications --> Utilities), give the command 'sudo apachectl start' and give your administrator password if requested.

In older versions of Mac OS 10, there is a "Web Sharing" item in the Sharing section of System Preferences which does the same thing.

Then create a folder named Sites in your top-level (home) folder: /Users/yourusername/Sites. This is the equivalent of the public_html folder that Apache usually uses for users' home folders on Linux/Unix systems.

A file named index.html in the Sites folder has the URL http://localhost/~yourusername/ . A file named hello.html would have the URL http://localhost/~yourusername/hello.html . And so on.

I maintain my website by keeping a complete copy on my Mac. I add new pages and images there first, test them, and then upload them to my public web site. This automatically gives me a complete backup of my website in case my web-host crashes or disappears. This came in handy when my old web-host at my college crashed and they decided not to continue having a public web server for faculty/staff/students. I bought a domain name, found a commercial web host, fixed my backup pages a bit to remove all links to the old server, and uploaded them to the new one.
 
Last edited by a moderator:

Similar threads

  • · Replies 22 ·
Replies
22
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 41 ·
2
Replies
41
Views
5K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
1K
Replies
4
Views
3K
  • · Replies 15 ·
Replies
15
Views
3K
Replies
11
Views
2K