Ignore document folders in URL path of sphinx project - python-sphinx

I'm constructing a Sphinx documentation and would like to place my .rst files in an organized folder structure. However, for my actual URL path I would like to not have these sub folders be included in the URL - rather, I would like to have a simple URL path as below:
[domain-url.com]/[file-name]
Is this possible to configure?

Related

How to access Sphinx-generated search index through static JavaScript files?

When Sphinx generates documentation, it also generates special searchindex.js file, which contains all of the documentation items. How to acess it from a JS script placed in _static?
In _static/myfile.js, you can reference the path from the root of the built docs, for example, /searchindex.js.

Middleman - How to change the paths for generated html files?

I'm building a website using Middleman. There are source files placed like the following.
source/index.html.md
source/errors/404.html
source/docs/foo.html.md
source/docs/bar.html.md
By default, when I build static html files, the generated files are placed following to the original directory structure (with directory indexes).
build/index.html
build/errors/404/index.html
build/docs/foo/index.html
build/docs/bar/index.html
However, I want all html files to be served directly under /, so that they can be accessed like http://example.com/foo/ and http://example.com/404/.
How do you change the paths for generated html files?
You can use proxies to create duplicate pages, and then ignore the original pages.
https://middlemanapp.com/basics/dynamic-pages/
But the simplest way is, of course, to adjust the source structure to match the desired structure.
I think this part of Middleman doc could help you .
All you need is to activate directory indexes and configure it properly, and it should work.

External Relative Link in Sphinx toctree directive

I'm using Sphinx to build my documentation. I'm using other tool for API reference. I have my docs in a directory and the API reference in directory name api inside of it.
I want to have a link from the documentation to the API reference. I'm able to add a link to my toctree link so:
.. toctree::
:maxdepth: 1
starting
glossary
main-use-case-flow
API Reference <http://www.example.com/lib/ios/0.1.0/api/>
The problem is I don't want to put a full path, I want to put just the relative path api/
How can I put a link to external resource using relative path and not absolute path?
I found one of the hackiest ways possible to do this. Basically Sphinx allows either a path to a document or an absolute path that requires http://. It turns out all they do to validate your link is look for literally http://.
*WARNING: toctree contains reference to nonexisting document u'downloads'*
Downloads <../downloads>
But if you do:
Downloads <../downloads#http://>
No warning! This does mean however that when the user clicks on your link, it inserts the http:// fragment or named anchor to your page link. If this is not a valid named anchor in your html, it will do nothing to your page (unless your page has some javascript that does something with the named anchor).
In the current version of Sphinx you can just put
.. toctree::
Title <http://LINK>
and it will work.
I encountered this problem when I tried to add links to (generated) javadocs to my toctree.
My solution was to create a phony index.rst in the appropriate location within my source tree to satisfy the requirements of toctree. I discovered the phony index.rst file must contain a title, so my file looked like this:
=======================
Java API (All Packages)
=======================
When you run make, this file gets copied into your build directory, _build/html (or whatever).
And then simply replace it with the real file after reStructuredText processing.
The following syntax works for me:
`Page Title <../relative/path.html>`

call .htc file from all html pages withot adding url domain

In that same CSS rule, add the following style line:
behavior: url(path/to/PIE.htc);
Of course you will need to adjust the path to match where you uploaded PIE.htc in step 2. Note: this path is relative to the HTML file being viewed, not the CSS file it is called from.
but if my url is domain.com/foo/foo.html PIE.htc is not loaded any more if i use
behavior: url(PIE.htc);
PIE.htc is located in root. Can i somehow always call .htc file from root?
URIs starting with a / are relative to the site root.
The behavior property requires the URI to the HTC file to be specified using the URL() syntax. Multiple HTC files can be referenced with a space-delimited list.
So suppose your csshover.htc file is in csshover directory and you can reference multiple HTC file or specially same file but from different directories
like behavior: URL('csshover/csshover.htc') URL('../csshover/csshover.htc') URL('../../csshover/csshover.htc') URL('../../../csshover/csshover.htc'); and so on.

Can the sitemap files be in a folder if the sitemapindex is in the root path?

I want to have a sitemap structure where the sitempasindex file is located in the root path (example.com/sitemaps.xml) and it references several sitemap[n].xml files located in a folder (example.com/static/sitemap1.xml). Those sitemap[n].xml files link to webpages that are in the rooth path (like example.com/helloworld.html).
Is that posible? I'm asking because I know that if the sitemap.xml file is placed within a folder, it can only contain webpages that are under that folder.
Thanks!
I believe you easily have
example.com/sitemap-index.xml
point to e.g.
example.com/sub1/sitemap.xml
and
example.com/sub2/sitemap.xml
however each sitemap.xml should only contains URLs within each their subfolder. (From your question, it seems you have those sitemap.xml files link to paths in root. I doubt that works, but you could try run a small test and submit to Google. If no errors then...)
The location of a Sitemap file determines the set of URLs that can be included in that Sitemap. A Sitemap file located at http://example.com/catalog/sitemap.xml can include any URLs starting with http://example.com/catalog/ but can not include URLs starting with http://example.com/images/.
From google perspective, they should be available on main root of the website. http://example.com/sitemap.xml, When you submit it through the subdir in webmaster tool "http://example.com/catalog/sitemap.xml" google won't crawl it and always showing us pending index status.

Resources