问题
I made a website using Node.js as the server. As I know, the node.js file should start working by typing commands in terminal, so I'm not sure if Github Pages supports node.js-hosting. So what should I do?
回答1:
GitHub pages host only static HTML pages. No server side technology is supported, so Node.js applications won't run on GitHub pages. There are lots of hosting providers, as listed on the Node.js wiki.
App fog seems to be the most economical as it provides free hosting for projects with 2GB of RAM (which is pretty good if you ask me).
As stated here, AppFog removed their free plan for new users.
If you want to host static pages on GitHub, then read this guide. If you plan on using Jekyll, then this guide will be very helpful.
回答2:
We, the Javascript lovers, don't have to use Ruby (Jekyll or Octopress) to generate static pages in Github pages, we can use Node.js and Harp, for example:
These are the steps. Abstract:
- Create a New Repository
Clone the Repository
git clone https://github.com/your-github-user-name/your-github-user-name.github.io.git
Initialize a Harp app (locally):
harp init _harp
make sure to name the folder with an underscore at the beginning; when you deploy to GitHub Pages, you don’t want your source files to be served.
Compile your Harp app
harp compile _harp ./
Deploy to Gihub
git add -A git commit -a -m "First Harp + Pages commit" git push origin master
And this is a cool tutorial with details about nice stuff like layouts, partials, Jade and Less.
回答3:
It's very simple steps to push your node js application from local to GitHub.
Steps:
- First create a new repository on GitHub
- Open Git CMD installed to your system (Install GitHub Desktop)
- Clone the repository to your system with the command:
git clone repo-url
- Now copy all your application files to this cloned library if it's not there
- Get everything ready to commit:
git add -A
- Commit the tracked changes and prepares them to be pushed to a remote repository:
git commit -a -m "First Commit"
- Push the changes in your local repository to GitHub:
git push origin master
来源:https://stackoverflow.com/questions/15718649/how-to-publish-a-website-made-by-node-js-to-github-pages