How to link index.html (gcloud app deploy)? - html

How would I link the index.html? I am deploying in Google Cloud Platform (using gcloud app deploy). This is so I can make the website with the html. I need a example with a html provided here (any of three html is fine). The index.html is where someone navigates to the root page of your website, what the person sees when clicking or going to the link of the site. My html specifically is just a "hello world" type website. And my files are located in my project (website-deploying-gc). This is the final step to create the site. Here is where the html is located (after getting into the files):
jinthemix#cloudshell:~ (website-deploying-gc)$ ls
app.yaml IMD233 Files README-cloudshell.txt README.md www
jinthemix#cloudshell:~ (website-deploying-gc)$ cd www
jinthemix#cloudshell:~/www (website-deploying-gc)$ ls
Mixs
jinthemix#cloudshell:~/www (website-deploying-gc)$ cd Mixs
jinthemix#cloudshell:~/www/Mixs (website-deploying-gc)$ ls
'Mix 1 (1)' 'Mix 2 (2)' 'Mix 3 (3)' 'Mix 4 (4)'
jinthemix#cloudshell:~/www/Mixs (website-deploying-gc)$ cd 'Mix (1)'
jinthemix#cloudshell:~/www/Mixs/Mix 1 (1) (website-deploying-gc)$ ls
'hello.html (B) (L2).html' 'hello.html (T) (L3).html' 'hello (L1).html'
jinthemix#cloudshell:~/www/Mixs/Mix 1 (1) (website-deploying-gc)$ cd
jinthemix#cloudshell:~ (website-deploying-gc)$ cd
Here is a reference link as well, that may provide more information. The site also talks about the index.html. The index.html is basically shows "hello world" to anyone viewing the website: https://cloud.google.com/appengine/docs/standard/python/getting-started/hosting-a-static-website
Any help is appreciated, thanks

I see the link you are using points to deploying a Python 2 application in App Engine. Take into consideration that the programming language itself (Python 2) is no longer supported by the community since at least January 1st 2020 so I'd strongly suggest you to use a similar tutorial for Python 3 (find the link here).
In order to serve static files (e.g. an index.html file that you are referring to) App Engine can handle URLs by executing application code (in the specific tutorial you are following this will consist on modifying your Flask application to serve a static file, as e.g. is described here), or by serving static files uploaded with the code and taking advantage of the handler element defined in your app.yaml file.
The comments within the app.yaml file on the tutorial I linked for Python 3 explain this in a very understandable way:
runtime: python39
handlers:
# This configures Google App Engine to serve the files in the app's static
# directory.
- url: /static
static_dir: static
# This handler routes all requests not caught above to your main app. It is
# required when static routes are defined, but can be omitted (along with
# the entire handlers section) when there are no static files defined.
- url: /.*
script: auto
Notice that you basically define a URL and use an element such as static_dir or static_files to serve that file when a customer lands that specific URL in your application.

Related

Deploy and host .net core 2.0 and angular 6 app

Intro:
Currently, I have two separate projects.
One solution is for .NET core Web API 2.0 and another project is Angular 6 app.
I have a problem deploying this to my hosting provider ( asphostsportal ).
It consists of one root folder httpdocs where when I publish my API I copy contents of publishing folder.
After transferring files via FTP I confirm that my API works by sending a request and getting the response.
Now I need to publish my angular project.
The simplest way to do so is with ng build and I get some folder in dist.
Problem:
If I transfer contents of the folder inside dist to my root folder httpdocs on server It can't find any page but API still works.
If I transfer the whole folder inside httpdocs and set server Host setting to define document root to that folder:
It will find the index.html and show me my landing page.
However then API won't work.
If I leave it as is and change the document root back to httpdocs ( where the API files are ) but push the index.html from httpdocs/website to httpdocs ( in this case I also edit index.html to point to website folder for resources etc ) in the hope it will find it ( server IIS setting )
It doesn't. After that my API starts working again. However, no landing page to be found.
Just FYI I do not have any extra startup.cs lines of code that have anything to do with static files nor did my publish command on API project create wwwroot folder ( like mentioned here)
Edit (Solution):
Okay, so I got it to work.
1) I added 2 lines of code in Configure method of Startup.cs in my API
app.UseDefaultFiles();
app.UseStaticFiles(); // For the wwwroot folder
Where according to MSDN
"With UseDefaultFiles, requests to a folder search for: index.html"
2) I manually added wwwroot folder which for some reason was not generating upon publishing command for my API project.
3) In that folder I copied all contents of my dist/website angular publish files
And now it works, cheers!

How do I redirect an old Netlify + Jekyll site address, to the new address?

I created a Jekyll site, hosted at Netlify, at old.address.com. Now I want to redirect to new.address.com. But the Netlify docs doesn't seem to work or I don't understand the docs. This is what I did:
I added, to _config.yml: (because Netlify says Jekyll excludes '_...' files)
include:
- _redirects
And I added a _redirects file. I just copy-pasted Netlify's generated instructions into that file, this is the content:
# Redirect domain aliases to primary domain
https://jekyll-comments.demo.ed.community/* https://jekyll-demo.talkyard.io/:splat 301!
http://jekyll-comments.demo.ed.community/* https://jekyll-demo.talkyard.io/:splat 301!
https://jekyll.demo.talkyard.io/* https://jekyll-demo.talkyard.io/:splat 301!
http://jekyll.demo.talkyard.io/* https://jekyll-demo.talkyard.io/:splat 301!
And this has no effect. What's the problem / what am I doing wrong?
This is how the directory looks like:
$ ls -1
404.html
about.md
_config.yml
Gemfile
_includes
index.md
_layouts
_posts
_redirects <—— added as per Netlify's instructions
_sass
_site
$ ls -1 _posts/
2018-01-01-like-about-jekyll.markdown
2018-01-02-installation-instructions.markdown
2018-01-02-kind-creatures.markdown
The config file is just the default one:
title: ...
email: ...
baseurl: "" # the subpath of your site, e.g. /blog
url: "" # the base hostname & protocol for your site, e.g. http://example.com
twitter_username: ...
github_username: ...
# Build settings
markdown: kramdown
theme: minima
plugins:
- jekyll-feed
talkyard_comments_server_url: ...
include:
- _redirects
Please note that although there are fairly many details above, it's all just various default stuff. So it's not specific to my problem. It should apply to all new Jekyll sites.
Disclaimer: I work for Netlify
We have a specific section on this in our documentation: https://www.netlify.com/docs/redirects/#handling-hostnames-and-protocols-differently
...and your snippet should work since it follows those conventions.
The only prerequisites to make that work are:
1) that you have your site configured in our UI to answer to ALL of those names - so:
jekyll-comments.demo.ed.community
jekyll-demo.talkyard.io
jekyll.demo.talkyard.io
2) and that all names are set up the same in DNS (CNAME to yournetlifysitename.netlify.com)
The only way to add "extra" names to your Netlify configuration is as domain aliases, which are configured in the Domain settings panel right next to your "main" custom domain.
Since your _redirects looks correct to me, if you have the prerequisites configured as suggested, the most likely failure mode is that you don't end up with your redirects actually applied for some reason (usually - they didn't get deployed because they didn't exist in a file called _redirects, in your publish folder, after the build), but your include in the jekyll config should allow that file to persist in that location. That jekyll config is the "right" way to do it but for other site generators, we sometimes advise people to copy the redirects into place after build: jekyll build && cp netlify_redirects.txt _site/_redirects
You can download whatever files are in your deploy to examine their "final state" via this tiny icon from any successful deploy logs page:
From a quick look at your site configuration, they appear to be deployed and working:
$ curl -v https://jekyll-comments.demo.ed.community/ -o /dev/null
* Connected to jekyll-comments.demo.ed.community (35.199.180.1) port 443 (#0)
[...]
< HTTP/1.1 301 Moved Permanently
[...]
< Location: https://jekyll-demo.talkyard.io/
So I guess the next question is...how are you testing?

Subdirectories in openshift project cannot be found

I built a site using a php openshift project and accessing the root directory via http works fine. However, all the root directories give me a 404 not found, like this one: http://test.toppagedesign.com/sites/
I checked with ssh, and /app-root/repo/sites and app-deployments/current/repo/sites/ both exist.
EDIT
Added a directory called php and now I have 503 errors for everything...
EDIT 2
I deleted the php directory, now the 503 errors are gone. However, I do still get 404 errors for the subdirectory.
Here is my directory tree: http://pastebin.com/hzPCsCua
And I do use git to deploy my project.
php is one of the alternate document roots that you can use, please see the March Release blog post here about this (https://www.openshift.com/blogs/openshift-online-march-2014-release-blog)
As for the sub-directories not working, can you ssh into your server and use the "tree" command to post the directory/file structure of your project? Also are you using Git to deploy your project or editing files directly on the server?
You need to have an index.php or index.html file in any directory that you want to work like app-domain.rhcloud.com/sites , if you just have sub-directories, how would it know what to show? Also, indexing (showing a folders contents) is not enabled for security reasons, and I believe there is no way to enable it.
This sounds like it could be a problem with how you are serving your static content.
I recently created a new sample app for OpenShift that includes:
a basic static folder
an .htaccess file (for serving assets in production)
support for using php's local server to handle the static content (in your dev environments)
Composer and Silex - a great starting point for most new PHP apps
You can serve the project locally if you have PHP-5.4 (or better), available in your dev environment:
php -S localhost:8080 -t static app.php
For a more advanced project that is built on the same foundation, take a look at this PHP+MongoDB mapping example. I wrote up a blog post with some notes on my process for composing that app as well.
Hope these examples help!

How to build a completely static multipage website with BEM?

All tutorials I've seen so far describe how to create single page sites or just several bundles. Here is an example of a simple website navigation:
example.com/home
example.com/about
example.com/services
example.com/services/marketing
example.com/services/development
example.com/contact
Is it possible to build such a site with bem-tools, bemjson, bemhtml but without any serverside tech like node.js or php?
The build should include only a directory with final .html, .css, .js files and images per page and should be hosted on a static file hosting like Amazon S3. It should also be an oldschool static website, not a single page ajax site.
Is there any easy to use solution for this use case or should one create her own build process to collect the files from the bundle directories?
Good question, and the answer is - yes, you can :)
First of all, you need to clone project-stub repo and install dependencies:
git clone git#github.com:bem/project-stub.git
cd project-stub
npm i
./node_modules/.bin/bem make libs
Now you have configured project stub to develop site with bem-tools.
Page index is included.
Let's create page about:
./node_modules/.bin/bem create -b about -l desktop.bundles/
This command creates file desktop.bundles/about/about.bemjson, which represents your page in BEM terms.
You can see this page when you run
./node_modules/.bin/bem server
and open http://localhost:8080/desktop.bundles/about/about.html in browser.
Read more: http://bem.info/libs/bem-core/1.0.0/bemhtml/reference/, "The Input Data: BEMJSON" chapter.
To get final css with rigth image path's, you need to install cssrb package:
sudo npm i cssrb -g
And to get final build directory, you need to put bem-static-build.sh file in root of your project and run it:
wget https://raw.github.com/alexbaumgertner/bem-static-build/master/bem-static-build.sh
sh bem-static-build.sh
After builder process ended, you can find static site in desktop.bundles/merged/build folder:
NB:
If you have content images on your page, you must put them into desktop.bundles/merged/img folder and make symlinks to all pages folders:
ln -s $(pwd)/desktop.bundles/merged/img $(pwd)/desktop.bundles/index/img
ln -s $(pwd)/desktop.bundles/merged/img $(pwd)/desktop.bundles/about/img
and etc for all pages. This actions are needed because bem server shows a page relative to its folder and with symlink you can write image src in about.bemjson and all pages like this:
{
block: 'user',
content: [
{
elem: 'avatar',
tag: 'img',
attrs: {
src: 'img/dypsilon.png' // relative way
}
}
]
}
and it should work!
Any questions are welcome!

How can I setup Jekyll for a blog with a large image directory, so as to avoid duplicating that directory in the generated site?

I'm considering Jekyll for a site I'm putting together that will be a blog with lots of images (and other larg-ish media files). It's easy enough to to make a directory for images and then link to them as needed in the posts. But, as I understand it, when the site is generated, all the image data will be duplicated into the generated _site directory that holds the static files. Each time the site is generated the _site directory is emptied, and repopulated with the static version of the site.
Is there any way to, for example, drop a symlink to the images directory inside the site directory, and then maybe have jekyll ignore it when the static files are generated?
Or is there another way to go about this that makes more sense?
Assuming you are running on an apache web server, you can setup an Alias directive to serve images from a directory outside of the normal docroot. You need access to edit the VirtualHosts config or some other ability to create aliases directives (e.g. via a control panel).
For an example of how this would work, let's say you are storing your jekyll files under a directory called "/web/jekyll". To get your images directory do the following:
Add an "_images" directory along with your basic jekyll tree. Ending up with something like:
_config.yml
_images/
_layouts/
_posts/
_site/
index.md
Update your apache config to add the Alias directive like:
Alias /images /web/jekyll/_images
Reload the apache config and run jekyll to build the site.
Since the image directory name starts with an underscore, jekyll won't push/copy it to the output _site during the build. Apache will happily serve most files from your _site directory as normal, but when it sees something like "http://jekyll/images/test.jpg", instead of looking for the file under "/web/jekyll/_site/_images/test.jpg", it'll serve it from "/web/jekyll/_images/test.jpg".
Incidentally, I like a little more separation of the source content and output content than jekyll defaults to. So, I setup my directory structure as follows:
/web/jekyll/html/
/web/jekyll/images/
/web/jekyll/source/
/web/jekyll/source/_config.yml
/web/jekyll/source/_layouts
/web/jekyll/source/_posts
/web/jekyll/source/index.md
With the following option set in _config.yml
destination: ../html
And the apache alias directive setup with:
Alias /images /web/jekyll/images
Jekyll is run in the "/web/jekyll/source" directory, but output is sent to the "/web/jekyll/html" dir. Similar to the first example, calls to "http://jekyll/images/test.jpg" are served from "/web/jekyll/images/test.jpg". This setup doesn't really make a difference from a site serving perspective. I just like the cleaner separation between the raw source files, the fully baked output files and the images which work via the alias.
Correct, the first part of the jekyll command removes everything in the destination directory. The problem with that is the symlinks must be manually created again. So next, go ahead and create a script that does this each time.
Be sure that:
exclude: [jekyll, css, img] in the _config.yml file
linux: The ";" symbol runs first, second, third.. commands.
script: A file named jekyll with executable permissions containing
jekyll;
ln -s /var/www/css /var/www/_site/css;
ln -s /var/www/img /var/www/_site/img;
Finally run (./jekyll) that program instead of jekyll.
-Dan
Make a project page for the images.
Set up directory structure
/home/git/svnpenn.github.io
/home/git/img
Run Jekyll
# We cant add the symlink until after jekyll is done. We will remove the
# site folder and wait for it to rebuild.
rm -r _site
jekyll --server &
while [ ! -f _site/index.html ]
do
sleep 1
done
ln -s ../images _site/images
Note I was using this because I thought it would help publish time on GitHub
pages. It does not. GitHub can take 1-10 minutes to publish depending on the
server.
I know this has already been answered, but I went a slightly different route. I hosted all of my images in a public directory on Dropbox and use grunt to generate a manifest of the images. It keeps my repository small because the images don't get checked in. I detailed it a while back in a blog post.