Default file other than index.html - jekyll

Is there a way to have a file other thing index.html or index.md served as a folder's default file? Specifically, I'm looking to keep my .json file extention, but have it reference-able as /api-docs/myapi/ instead of /api-docs/myapi/myapi.json.

This configuration is mostly in your web server. You can set the files for the server to look for to index.json (as well as index.html and index.htm which are common on most servers). For example, this can be configured on nginx by adding this to your server block:
index index.json index.html index.htm;
If nginx gets a request for /some/folder, it will try to serve /some/folder/index.json, /some/folder/index.html, /some/folder/index.htm then your 404 page with this configuration.

You can use permalink in your yaml front matter :
Permalink: api-doc/myapi/myapi.json
Edit: As #SAMdroid pointed it, I misunderstood the question, and as he says in is answer, it's a server configuration matter. But, it's sadly not possible to change default served page on Github Pages.
Your json can only be reached at api-doc/myapi/myapi.json

Related

HTML Domain and Path

I was learning about HTML domains and paths in my computer-science class. However, I have a question. What happens if you only specify a domain, such as apple.com instead of specifying a path? Does the page automatically give you the index file or something?
Thanks :)
That entirely depends on what the web server is configured to do. What you’re doing is you’re requesting a URL from a web server via HTTP. That does not inherently have anything to do with files. The web server can respond to the request in any way it wants.
But yes, most typically the average web server will look for a file named something like index.html in its webroot folder and return it.
yes, there is the default file that is returned if no path is provided
From Apache documentation
Typically, a document called index.html will be served when a directory is requested without a file name being specified. For example, if DocumentRoot is set to /var/www/html and a request is made for http://www.example.com/work/, the file /var/www/html/work/index.html will be served to the client.
From IIS documentation:
Default documents are enabled by default, and IIS 7 defines the following default document files in the ApplicationHost.config file as server-wide defaults: Default.htm, Default.asp, Index.htm, Index.html, Iisstart.htm.
(If you install ASP.NET on your Web server, the installation process will add the Default.aspx file to this list.)

Permanently redirect Jekyll pages to external site without markdown?

Using Jekyll/Github pages. As part of a content overhaul, we've moved a lot of pages to an external site. We'd like to clean up our Github pages repository and remove all purged files while providing a 301 redirect to the new domain where they now live.
The problem is that - according to my understanding of the docs - you must have a markdown file present with a redirect_to field. This defeats the purpose of purging the files in our repo. Is there a way to configure redirects from the _config.yml file or a plugin that allows me to do this from a single file?
I cannot see how this can be possible on the GitHub platform. As you mentioned, you can use the jekyll-redirect-from plugin but you cannot automate it through config or other data files because Jekyll sites are static and thus, the server will only look for the directory and an index file within it for each URL.
The only way you can achieve this without keeping the file structure is to move the site to a server where you configure URL rewrites within the web server such as Nginx or Apache.

My website doesnt load index.html if i dont write it manually

I recently bought a website to play with, but I immediately had a problem.
My website doesn't load the index.html when I just connect to mydomain.com. If I write it manually (mydomain.com/index.html) everything works perfectly. I tried to change the .htaccess file to direct all traffic to my index.html page with the following line, but the problem remains:
DirectoryIndex index.html
Any ideas to solve the problem?
Please provide the web host and/or server type (windows, linux, etc) to help further answer your question.
As a start some web servers (windows/iis) expect different file names for the default html file. Godady.com has a list of different file names for Linux and Windows at this url: https://www.godaddy.com/help/what-file-displays-when-someone-browses-to-my-domain-name-60
Good luck!
This DirectoryIndex index.html has to be set in httpd.conf file. In your httpd.conf, you might have disabled .htaccess with AllowOverride none. That is why your .htaccess is not working

Index.html file is named as parent directory?

I have an contact.html file on the server in public_html.If I Move it into directory named: Contact, & rename it to index.html,does browser's Address bar shows it like: example.com/Contact/ ? I mean the name of file doesn't show up.
ANY help is appreciated.
Yes, example.com/Contact/ would work, but only if the server is configured with a default document index.html.
This is standard behaviour for apache web servers.
In your apache config there is a directive called
DirectoryIndex index.html ...
This tells the webserver to serve index.html in the case that a directory call was requested ... ie your example.com/Contact/ [Is a directory].
To change that behaviour you would need to look into change your server config, or adding an .htaccess file that would rewrite the URL to index.html

Basic HTML - does relative path to a sub-folder (using the directory name) work on a desktop?

I am doing some basic HTML exercises on a Mac OS 10.6.6.
Say I am here:
rootfolder/index.html
and I want to go here:
rootfolder/subfolder/index.html
I understand I can use the relative path to make a link:
link to subfolder
^ this works for me in my browser.
And if I wanted to shorten the href, I could just do this:
link to subfolder
When I click the short version in my browser, the link takes me to the folder on my desktop (not to the page in my browser)
I'm wondering, do the files need to be in a web host environment for
the short version to work in a browser?
When /bob/ => /bob/index.html works, it is generally because the server has listed it as its directory index, e.g. with Apache...
DirectoryIndex index.html index.php
...meaning in the request of a folder, it will first look up to see if an index.html or index.php exists (in that order).
So if you are running it from the folders of your local filesytem (i.e. on the file: protocol), it has no server and does not know that a blank directory should request index.html.
The serving of index.html (or index.cgi or default.asp or whatever) when requesting a url that points to a directory is done by the server, not the browser. It is usually done as a result of configuration setting.
It's neither a property of HTML nor a property of urls.
If your browser doesn't serve index.html — and I don't know any that do — then you've answered your own question.
Mac OS comes with Apache (the most commonly-used open-source web server) pre-installed. You can set it up by going to System Preferences, choosing the "Sharing" preference pane, and then checking the box to turn on Personal Web Sharing.
Once you've turned on Personal Web Sharing, http://addressofyourcomputer/~yourusername/ will point to the Sites directory in your user's folder in Mac OS (i.e., /Users/yourusername/Sites/). With Apache running, if you go to http://addressofyourcomputer/~yourusername/subfolder/, it will in fact serve up /Users/yourusername/Sites/subfolder/index.html if there is an index.html file in that subfolder.
Without turning on Personal Web Sharing, though, there is no server running, and so your browser is really just directly accessing your computer's filesystem. As a result, when you ask for a folder, it literally returns you that folder, whereas Apache server knows the convention that /subfolder/ is really a request for /subfolder/index.html and will re-direct you accordingly.
The default page setting/redirection works only on web servers. The browser do not have intelligence(?) for such redirection. So the second option will not work.