Local web page programming on a Mac

In summary, you can save a plain text version of your website by choosing "Make Plain Text" in the Format menu of your text editor, and then saving the file with an .html extension.
  • #1
tony873004
Science Advisor
Gold Member
1,752
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
  • #2
You can save it as a txt file, then change the extension.

I suggest you install and use Emacs.
 
  • #3
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.
 
  • #4
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.
 
  • #5
Thanks! That worked.
 
  • #6
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:

Related to Local web page programming on a Mac

1. What is the best web programming language to use on a Mac?

The best web programming language to use on a Mac depends on personal preference and the specific needs of the project. Some popular options for local web page programming on a Mac include HTML, CSS, JavaScript, and PHP.

2. Can I use a Mac to develop and test my local web pages?

Yes, you can use a Mac to develop and test your local web pages. Macs come with pre-installed web browsers, such as Safari and Chrome, which can be used to preview and test your web pages.

3. Do I need any special software to program local web pages on a Mac?

You do not need any special software to program local web pages on a Mac. Macs come with a built-in text editor, called TextEdit, which can be used for basic web page programming. However, there are also many third-party text editors and web development tools available for Mac users.

4. Are there any limitations to programming local web pages on a Mac compared to other operating systems?

No, there are no major limitations to programming local web pages on a Mac compared to other operating systems. Macs support a wide range of web development languages and tools, making it a popular choice for web developers.

5. Can I easily transfer my local web pages from a Mac to a different operating system?

Yes, you can easily transfer your local web pages from a Mac to a different operating system. As long as the necessary web development languages and tools are installed on the new operating system, you should be able to transfer your files and continue working on your project seamlessly.

Similar threads

  • Programming and Computer Science
Replies
22
Views
952
  • Programming and Computer Science
Replies
32
Views
2K
  • Programming and Computer Science
2
Replies
41
Views
3K
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
4
Views
760
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
11
Views
894
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
11
Views
1K
Back
Top