How to migrate hugo site from localhost to Linux server - hugo

I am new in Hugo and I already created the home page ready with prebuild theme which I found on https://github.com/giraffeacademy/ga-hugo-theme but now I want to make it live on my Hostgator server so what I did after override my theme I run the command
from hugo server -D to hugo
then I see the public folder and I just used that and make it live here
http://webdemoapp.com/Bravocore/
my question is: Is this the right way to make it live? or have to install the hugo server on hostgator?
Note:I have window10 where I am working with hugo server

TLDR: Using just hugo is the right way. Source: Hugo Docs
The hugo server command is normally used for debugging purposes. To build the page itself use just hugo as command and it will generate the content within the public/ folder. You can then just upload everything to your hoster. There it should be distributed through e.g a Apache or Nginx webserver. Those are mostly preinstalled.

Typically, you should run hugo and hugo server only on your local machine where you also write the content for your website. When you run hugo, it will generate static HTML, CSS and JS which you should then upload to an appropriate webhoster or other server.
The whole point of static site generators is not having to run much or any specific backend stuff on the server to render the content of your website.

U don't need to install Hugo on ur server. Build the Hugo site by running Hugo and then the build will create a set of files which will be basic HTML pages, Upload the files to the server. The server can serve these Html pages.
U can run a Hugo site without a server bu using Netlify, Upload your code to Git repo and link the repo to Netlify then deploy your site.

Related

Serve any pre-built static site using Hugo server command?

Is it possible to serve a static site, not necessary a hugo one, using hugo server command?
cd /path/to/some/static_site
hugo server [option for watching and serving site(NO BUILDING)]
The idea is to use Hugo as a live server during development
even for none Hugo sites since it does the job well. Was hoping
to avoid pulling in additional build dependency.
Instead of using the command hugo server, you can just use the command hugo (without any option), and Hugo will render all the content to the /public directory. Then, configure your hosting so that your website points to this directory and you will have a static site.
You can alos use hugo --minify if you want to minify your content in the /public directory.

React-snap build fails unless build folder is uploaded to server

I'm using ReactJS and need some help with the build.
I am hosting a static site on a dedicated server.. in order to process that site I currently run my build locally and upload the 'build' folder to the server.
I've recently decided I should probably generate some static files for SEO (and adsense approval) and therefore I've added react-snap.
I run npm run build from my directory, and react-snap runs postbuild as expected however it fails unless I upload the build to the server first and then run the same build again to generate the static files (and then have to upload these again to the server for the static content to be available for search engine crawling).
I'm obviously missing a fundamental step in my build process here. I already want to refine it to a Git and push that to the server but I don't think this will help my react-snap problem.
Can anyone help?
Answering my own question for anyone with this problem...
My production variable for homepage was set specifically to the domain.. this is not required and does not allow for local crawling of the site. Explanation here:
https://github.com/stereobooster/react-snap/issues/153

Deploy Gatsby on Godaddy Sever

Can I deploy Gatsby static pages on Godaddy server? I am not sure if that's possible.
If you have SSH/SFTP access to your server on GoDaddy (which you should), you can use any CI tool to deploy your Gatsby site.
Tools you can use are for example:
Buddy
CircleCI
Another option is to use a hoster specialized on static pages like github pages or netlify.
If you want to deploy your static website on a normal server without CI, you can run
gatsby serve -p 80 -H <your private IP address>. Replace with the IP address you get from ifconfig on linux or ipconfig on windows.
I end up building my own framework with ReactJS, now all I have to do is execute
npm run build
to create an optimized build in build directory
Zip everything from build folder.
Go to godaddy CPanel->filemanger-> public html
Upload the zip file from build folder into public html
Right click to unzip it and we are good to go
See the live demo http://hiteshsahu.com/topics

Express JS serve react js files

I have an express js backend and a react js frontend.
Now i want to serve this as one project.
Is it possible to build a task with webpack, grunt etc. to build the react js first and then move the build to the public folder in express js?
There is! You can serve your static client files (your react app) from your server. I would suggest checking out this article if you want to know how to do so https://originmaster.com/running-create-react-app-and-express-crae-on-heroku-c39a39fe7851
Yes you can. You need to make a production build which will place all files in a directory; let's say "dist" directory. Now you can run express server or any other server (lite-server suggested) and set base directory as "dist" which will run index.html by default and your app will be running in production mode.
You can read official article from Facebook here :
https://reactjs.org/docs/optimizing-performance.html

Can I deploy react.js web app to a share hosting?

I am wondering if it is possible to deploy react.js web app that I've built to a share hosting site that does not have node.js installed?
I use webpack to build the application and it creates normal html, js, css file. I uploaded the static folder that includes all those html, js(bundle.js) and css files, but when I request the site, the server reply with 404 bundle.js not found response.
Use npm run build, you should get a folder with the index html file inside that will run your app. Try this with xampp first before you actually deploy to your server.
Here is everything step by step
npm run build
or
yarn run build
it will generate a build folder that looks like this:
Copy everything and move it to the htdocs in xampp or ftp upload the directory to the public_html file in your hosting
Yes you sure can put react on a shared hosting provider.
Seeing as you're getting a 404 error (not found), you are probably referencing your react file/bundle incorrectly. It might not even be named bundle.js if you're using a boilerplate to create your application.
Can you give more information? What does your index.html file look like? What does your directory structure look like? If you are able to post these files I can tell you what the issue is.
Update:
The answer below should be accepted. (Although this would assume that you have the ability to make a build which you have not verified or not.)
Make a build using the build command through whatever boilerplate you used. Deploy those files on your shared hosting server. Make sure that index.html is at the root of where your server is expecting the root to be and your app should be live.
For deploying a react app on a shared hosting you need to create a production build. Production build is a pack of all your react code and its dependencies.
in most shared hosting we put our site/app inside a public_html directory so if we hit www.yourdomain.com it serves the code from public_html directory.
so if your react app is ready to go, edit your package.json file add a new key value:
"homepage":"http://yourdomain.com"
then create a build using following command:
npm run build
after running the command you will see a new directory named build in your app root. It will contain js and css for the app and a index.html file. You need to upload all the content inside build directory to public_html directory, and that's all, go to your domain and your app will be working just fine.

Resources