HUGO + GitHub Pages: How to set up subdomain - subdomain

I have a github repository that I want to add my hugo site to. From the docs folder in my repository I can run github pages.
Therefore, I have changed my publishDir parameter in the hugo config to docs.
publishDir = "docs"
Now when I build hugo it ouputs everything in the docs folder which is great, the issue is running a subdomain from there.
How do I get a subdomain on hugo that is generated into my docs folder that acts like a subdomain on github pages?
I know I would need to use a CNAME and then tell it to say /docs/subdomain is actually subdomain.site.com
but I am not sure how to set that up in HUGO. and where do I put the subdomain folder? in the static folder so it would be theme_name/static/subdomain which would ouput into the docs like docs/subdomain?
If this is the way, can I use all the parameters and shortcodes in my static folder?
Also, if I need to create 2 hugo installations, one for the main site and one for the subdomain site, is their a way to share site params, configs, static files and layout files etc… ?

You have to create a custom script to create two different builds and then
Add a CNAME file to your project's repository. The content of this file must be a single line specifying the bare subdomain for your project's custom subdomain (e.g. pjname.mydomain.com).
In your DNS provider's settings, create a new CNAME record that points project name to either the root (usually denoted by #), if you have previously set up an apex domain, or to myusername.github.io if you've set up a custom subdomain. It should look something like this:

If you have two sites that you want to serve separately under two domains/subdomains (or even subpath), it's better that you create two different repositories for that.
In your username.github.io repository, you are using the "docs" folder to serve your site. However, this procedure will not work for other repositories. To serve from other repositories, name the repo whatever you like and create a "gh-pages" branch on it. The branch root must contain the entire site. You can access this site using username.github.io/your-repo-name/.
In this new repo you can add a CNAME. Hope this works. I did almost the same thing, except that I used subpaths instead of subdomains. Here's my main profile rafed.github.io and my blog rafed.github.io/devra/

Related

Can't use Git Pages

TLDR: GitHub Pages isn't working.
I have a little knowledge on GitHub and tried multiple fixes to no avail. One repository is only showing readme file contents.
Please explain in lamest terms.
New to web development, I finally was able to complete my first site, but I'm unable to actually deploy the files for some reason; please forgive me, I literally have no idea what any of the git terminologies are.
I purchased a pro subscription in order to keep the repository private and the site public.
Every file is present in what seems to be the main root directory, but nothing is being actually presented.
I've created two different repositories in an effort to fix this, as I've seen different methods are available.
The first repository includes a README file because I was originally instructed to do so, however, all the site link does is present that README file's contents;
I also attempted to add a permalink fix within the file, but all it did was add that text to the other text presented.
The second repository in question literally greets me with nothing but a 404 error.
The solution I tried for the second repository was to have the repository name share my username as well since that seems to be where the site's link originates, but no present changes have occurred.
Finally, the waiting game solution hasn't beared any fruit yet either aside from updating the README file's contents.
All help is very much appreciated.
Check first:
Your GitHub repository name, which depends on the type of GitHub Pages you are creating
If you're creating a user or organization site, your repository must be named <user>.github.io or <organization>.github.io.
your GitHub Pages Publishing source
If you use the default publishing source for your GitHub Pages site, your site will publish automatically. You can also choose to publish your site from a different branch or folder.
You can add more pages to your site by creating more new files.
Each file will be available on your site in the same directory structure as your publishing source.
For example, if the publishing source for your project site is the gh-pages branch, and you create a new file called /about/contact-us.md on the gh-pages branch, the file will be available at https://<user>.github.io/<repository>/about/contact-us.html.
Make sure you have GitHub Pages enabled for every repository and that it's set to the branch you want to publish by checking your Pages settings at github.com/<user>/<repo>/settings/pages. If enabled, there should be a link on that page that takes you to the site.

hosting multiple github pages from one github repository

I have github repository which contains 4 different folders named module2/3/4/5 solutions respectively each containing index.html and style.css files which are a part of a coursera course i am currently pursuing....now i can't figure out how to host all these 4 different pages separately from this one repository....all tutorials and documentation tell to create a new repo named username.github.io and simply push the index.html and it'll work which i understand....but i don't want 4 different repositories for solutions of different weeks...rather i would like to host all 4 independently form this very same repository....please tell me what to do?
I want my repository to look like this guys repsitory
https://github.com/siddartha19/Coursera-HTML-CSS-and-JavaScript-for-Web-Developers
as you can see all the different module solutions are hosted from this repository....
The architecture of the github page website mirror the architecture of the repository.
From your example, one of the page's URL is:
https://siddartha19.github.io/Coursera-HTML-CSS-and-JavaScript-for-Web-Developers/Assignments/module-3/index.html
The repository name is 'Coursera-HTML-CSS-and-JavaScript-for-Web-Developers' - It contains a folder 'Assignments' which contains 'module-3' which contains an index.html file.
Do you see how the URL format mirrors the structure of the folders?
If you want your github page to have the same architecture you can just do the same folder structure.
This can be achieved through netlify. Once you've registered, add project -> select git repo. Remember to change the base URL to let's say module2/index.html.

How to redirect readthedocs web pages to other website

We started having our project's docs on readthedocs site (say http://abc.readthedocs.org). For various reasons we now moved to our own web servers with new domain (http://abc.io).
We want to bring down http://abc.readthedocs.org gracefully so that our project documentation is not broken all across the internet.
One way we are thinking is to have "redirects" from all pages with prefix (http://abc.readthedocs.org) to (http://abc.io).
But, I don't see any redirection options in readthedocs site that provides redirection to completely new domain. Readthedocs only allow redirection within different pages under same domain.
Any pointers on how I can proceed would be very helpful.
Read the Docs offers several kinds of user-defined redirects:
Prefix redirects (e.g. /dev/... -> /en/latest/...)
Page redirects (e.g. [/$lang/$version]/example.html -> [/$lang/$version]/examples/intro.html)
Exact redirects (e.g. /dev/install.html -> /en/latest/installing-your-site.html)
To migrate from an old Read the Docs project to somewhere else, the project is more involved:
Add an Exact Redirect from /$rest to https://new.domain/
Deactivate all versions of the old project, except latest (which can't be deactivated)
Create a repository with a Sphinx project that only contains an index.rst with the following markup:
.. meta::
:http-equiv=Refresh: 0; url='https://new.domain/en/latest/'
Change the repository URL on https://readthedocs.org/dashboard/oldproject/edit/ to such repository
I added the following section to my index.rst:
.. raw:: html
<script type="text/javascript">
if (String(window.location).indexOf("readthedocs") !== -1) {
window.alert('The documentation has moved. I will redirect you to the new location.');
window.location.replace('http://cosmo-docs.phys.ethz.ch/cosmoHammer');
}
</script>
On the ReadTheDocs Admin page, the "Exact Redirect" form of redirection allows other domains in the "to URL" field. But it only seems to redirect one page per rule. That is, it requires an "Exact" match. I was hoping for some mod_rewrite magic using (.*) and $1. But that is not set up.
Another idea that works (but is clunky) is to create a temporary repository with a docs folder that uses markdown. The index.md file can consist of a refresh:
<meta http-equiv="refresh" content="0; URL=https://new.location">`
You can also add html with a direct link in case the refresh doesn't work.
The conf.py file can be:
from recommonmark.parser import CommonMarkParser
source_parsers = {'.md': CommonMarkParser}
source_suffix = ['.md']
master_doc = 'index'
Commit this repository to github (or other host) and change the project URL for your RTD project to this temporary repository. You can create tags for the temporary repos. to match those of your actual repository. Then make sure ReadTheDocs builds each version. If all goes well, the home pages of each version will redirect to wherever your refresh sends them.
It would be nice if the Redirects available on the Project Admin page would allow redirects of prefixes to other domains.

GitHub Pages: Octopress in Subfolder (other pages in root)

I'm in the process of moving my blog from self-hosted Wordpress to (GitHub-pages powered) Octopress.
Thus far, I have successfully set up & copied my blog over to myusername.github.com, which has the CNAME http://mydomain.com. (So, browsing http://mydomain.com shows my Octopress blog. Dandy.)
I would like to modify my setup so that things are as follows:
http://mydomain.com → Simple html landing page
http://mydomain.com/blog → Octopress blog, in all its glory
http://mydomain.com/sdf → Miscelaneous other simple html sites that I would like to host
http://mydomain.com/sdfsdfdsf -> As above
... (an arbitrary number of other root-level sites)
However…I would like my landing page (and other misc sites) to be hosted from the GitHub-pages repo, and the source stored alongside Octopress.
Ideally, «octopress»/source/ would look like this:
«octopress»/source/index.html → My landing page
«octopress»/source/blog/* → Normal Octopress source folder (contains _posts, assets, _layouts, etc.)
«octopress»/source/sdf/index.html → Other misc sites
Thus far, I have found instructions about how to deploy Octopress to a subdirectory. But as far as I can tell, these instructions don't allow you to have other misc sites under «octopress»/source/.
I would love suggestions about how to accomplish what I'm after. I have a feeling it won't be hard (just tweaks to some Jekyll files somewhere, perhaps).
Many thanks,
You can change your blog index page to blog/index.html like the document describes. Then, put your landing page and other sites into /source directory.
If you are running Jekyll locally rather than using the version on the github server, you don't need to do everything within Jekyll - simply have a shell script move some folders around between the generate and deploy steps.
After Jekyll runs, everything is static files, and the deployment step is just committing and pushing whatever happens to be in the output folder at that point.

deploy website to cd - paths

what's the best way of porting a static HTML website to a CDROM, to allow users to insert the disk, copy the files off, and then run the site "offline", as it were.
what sort of path structure should i use? at the moment all of the assets are like:
file:///C:/Users/User/Desktop/MySite/index.html
which obviously isn't very portable
thanks for any info
You should use relative paths, like
index.html
and
images/img.gif.
If you have many absolute links, search for "file:///C:/Users/User/Desktop/MySite/" and replace all with "" (or "./", to make things clearer). Notepad++ can search across all files of one directory.
To make things even clearer, create a subdirectory with all files and more subdirs and optionally an index.html in the root directory, so the user only has to copy one folder (plus one index.html).
You can try to use portable web-server application.
This application allow to run any websites on any drives (USB-Flash or CDROM). The main advantage that you shouldn't to change links from absolute paths to relative. Also, the application will open your sites if that uses a database or PHP.
For example: XAMPP (Portable Web Server) and many others.