Thank Juh
I created the following base on your example.
It works, but not perfect. It would be nice to support full directory
redirection, not file by file
# Generate a redirection HTML file
def write_html_redirect(redirect_to):
html = "<html><head><meta http-equiv=\"refresh\" content=\"0; url=" +
redirect_to + "\"></head></html>"
return html
# Read a YAML dictionary of redirections and generate an HTML file for each
redirects_file = "_utils/redirections.yaml"
def create_redirects(app, docname):
if not os.path.exists(redirects_file):
return
if not app.builder.name == 'dirhtml':
return
with open(redirects_file, 'r') as yaml_file:
for from_path, redirect_to in yaml.load(yaml_file).iteritems():
print "generate a redirection HTML file from: " + from_path + "
to: " + redirect_to
target_path = app.outdir + '/' + from_path
if not os.path.exists(target_path):
os.makedirs(target_path)
with open(os.path.join(target_path + '/index.html'), 'w') as
t_file:
t_file.write(write_html_redirect(redirect_to))
...
def setup(sphinx):
...
sphinx.connect('build-finished', create_redirects)
On Tuesday, July 31, 2018 at 3:29:07 PM UTC+3, Jan Ulrich Hasecke wrote:
>
>
>
> On 31.07.2018 07:14, Tzach Livyatan wrote:
> > Thanks
> > This solves the internal links issue (in a nice way!) but not links from
> > external domains.
>
> Maybe this can help you:
>
> https://tech.signavio.com/2017/managing-sphinx-redirects
>
> juh
>
> --
> Software-Dokumentation mit Sphinx
> http://www.amazon.de/dp/1497448689/
> Paperback: 224 Seiten
>
--
You received this message because you are subscribed to the Google Groups
"sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sphinx-users.
For more options, visit https://groups.google.com/d/optout.