简体   繁体   English

冷冻瓶创建文件,但链接错误

[英]Frozen flask creates the files but gets the links wrong

Using frozen flask to make my website static, I have the following problem. 使用冷冻瓶使我的网站保持静态,我遇到以下问题。

While all of my pages are being built ( file//c:/correctpath/build/2014/page-title/index.html ) the links to the pages are file:///c:/2014/page-title/ . 虽然所有我的网页正在建设file//c:/correctpath/build/2014/page-title/index.html )链接到页面file:///c:/2014/page-title/

Is there something I have missed? 有什么我想念的吗?

EDIT : 编辑
In my template I have something like 在我的模板中,我有类似

 {% for page in pages %}

             <a href="{{ page.url() }}">{{ page.title }}</a>
 {% endfor %}

where .url() is a method on the page object: 其中.url()page对象上的方法:

return url_for('article', name=self.name, **kwargs)

url_for produces absolute paths (eg /2014/page-title ) - when you open up your files in the browser it follows the rules regarding relative URL resolution and strips the extra file contents. url_for产生绝对路径(例如/2014/page-title )-在浏览器中打开文件时,它遵循有关相对URL解析的规则,并去除多余的文件内容。 If you just want to view your files as they will be seen on the server, Flask-Frozen has a run method that will let you preview your site after generating it. 如果您只想查看文件,就可以在服务器上看到它们,Flask-Frozen提供了一种run方法 ,可让您在生成网站后预览网站。

Alternately, you can set FREEZER_RELATIVE_URLS to True to have Flask-Frozen generate links with index.html in them explicitly. 或者,您可以FREEZER_RELATIVE_URLS设置为True以使Flask-Frozen显式地生成带有index.html链接。

您也可以将FREEZER_BASE_URL设置为<http://your.website/subdir> ,而不是将FREEZER_RELATIVE_URLS = True设置FREEZER_RELATIVE_URLS = Trueindex.html结尾的URL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM