Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Local web page programming on a Mac

  1. Jan 8, 2016 #1

    tony873004

    User Avatar
    Science Advisor
    Gold Member

    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.
     
  2. jcsd
  3. Jan 8, 2016 #2

    DrClaude

    User Avatar

    Staff: Mentor

    You can save it as a txt file, then change the extension.

    I suggest you install and use Emacs.
     
  4. Jan 8, 2016 #3

    tony873004

    User Avatar
    Science Advisor
    Gold Member

    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.
     
  5. Jan 8, 2016 #4

    DrClaude

    User Avatar

    Staff: Mentor

    In the Format menu, choose "Make Plain Text". It converts to plain text and will save automatically with an extension .txt.
     
  6. Jan 8, 2016 #5

    tony873004

    User Avatar
    Science Advisor
    Gold Member

    Thanks! That worked.
     
  7. Jan 9, 2016 #6

    jtbell

    User Avatar

    Staff: Mentor

    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/ [Broken] . A file named hello.html would have the URL http://localhost/~yourusername/hello.html [Broken] . And so on.

    I maintain my web site 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 web site 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: May 7, 2017
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Local web page programming on a Mac
  1. Web page table (Replies: 2)

Loading...