页面

Odoo allows you to create pages for your website and customize their content and appearance to your needs.

Static pages have stable content, such as the homepage. You can manually create new ones, define their URLs, adapt their properties, etc. Dynamic pages, on the other hand, are generated dynamically. All pages generated automatically by Odoo, for example, when you install an app or module (e.g., /shop or /blog) or publish a new product or blog post, are dynamic pages and are therefore managed differently.

页面创建

网站页面可以从**前台**和**后台**创建。创建新网站页面的步骤如下:

    • Either open the Website app, click + New in the top-right corner, then select Page;

    • Or go to Website ‣ Site ‣ Pages and click New.

  1. Enter a Page Title; this title is used in the menu and the page’s URL.

  2. 点击:guilabel:创建

  3. Customize the page’s content and appearance using the website builder, then click Save.

  4. Publish the page.

注解

Disable Add to menu if the page should not appear in the menu.

页面管理

发布/取消发布页面

Pages need to be published to make them accessible to website visitors. To publish or unpublish a page, access it and toggle the switch in the upper-right corner from Unpublished to Published, or vice versa.

Unpublished/Published toggle

注解

It is also possible to:

  • publish/unpublish a page from the page properties, where you can define a publishing date and/or restrict the page’s visibility if needed;

  • publish/unpublish several pages at once: go to Website ‣ Site ‣ Pages, select the pages, then click Action and select Publish or Unpublish.

主页

When you create a website, Odoo creates a dedicated Home page by default, but you can define any website page as your homepage. To do so, go to Website ‣ Configuration ‣ Settings, then, in the Website info section, define the URL of the desired page in the field Homepage URL (e.g., /shop).

Alternatively, you can define any static page as your homepage by going to Website ‣ Site ‣ Properties. Select the Publish tab and enable Use as Homepage.

页面属性

To modify a static page’s properties, access the page you wish to modify, then go to Site ‣ Properties.

The Name tab allows you to:

  • 使用 页面名称 字段重命名页面;

  • 修改 页面 URL。在这种情况下,您可以根据需要将旧 URL 重定向到新 URL。为此,请启用 重定向旧 URL,然后选择 重定向类型

    • 301 永久移动:永久重定向页面;

    • 302 临时移动:临时重定向页面。

    重定向旧 URL

您可以在 发布 选项卡中进一步调整页面属性:

  • 在顶部菜单中显示: 如果不想让页面出现在菜单中,请禁用;

  • 用作主页:如果希望将页面作为网站主页,请启用;

  • Indexed: Disable if you don’t want the page to be shown in search engine results;

  • Published: Enable to publish the page;

  • 发布日期:要在特定时刻发布页面,请选择日期,单击时钟图标设置时间,然后单击绿色复选标记验证您的选择。

  • 可见性:选择谁可以访问页面:

    • 全部

    • Signed In

    • Restricted Group: Select the user access group(s) in the Authorized group field.

    • With Password: Enter the password in the Password field.

小技巧

Some of these properties can also be modified from Website ‣ Site ‣ Pages.

复制页面

要复制页面,请访问该页面,然后转到 站点 ‣ 属性 并单击 重复页面。输入 页面名称,然后点击 确认。默认情况下,新页面会添加到菜单中复制页面的后面,但您可以使用 菜单编辑器 从菜单中移除新页面或更改其位置。

删除网页

删除页面的步骤如下:

  1. 访问页面,然后转到 站点 ‣ 属性 并单击 删除页面

  2. 屏幕上会弹出一个窗口,按类别显示所有指向要删除页面的链接。为确保网站访问者不会进入 404 错误页面,必须更新网站上指向该页面的所有链接。为此,请展开一个类别,然后点击一个链接,在新窗口中打开它。或者,也可以为已删除的页面设置 重定向

  3. 更新链接(或设置 重定向)后,选择 我确定这样做 复选框,然后单击 确定

URL redirect mapping

URL redirect mapping consists in sending visitors and search engines to a URL different from the one they initially requested. This technique is used, for example, to prevent broken links when you delete a page, modify its URL, or migrate your site from another platform to an Odoo domain. It can also be used to improve Search Engine Optimization (SEO).

To access existing URL redirections and create new ones, activate the developer mode and go to Website ‣ Configuration ‣ Redirects.

注解

要创建新的重定向,请点击 新建 按钮,然后填写字段:

  • 名称:输入名称以标识重定向。

  • 操作:选择重定向类型:

    • 404 未找到页面:当访问者试图访问未发布或已删除的页面时,会被重定向到 404 错误页面。

    • 301 永久移动:用于永久重定向未发布或已删除的 静态页面。新 URL 会显示在搜索引擎结果中,重定向会被浏览器缓存。

    • 302 暂时移动:用于短期重定向,例如,在重新设计或更新页面时。新 URL 既不会被浏览器缓存,也不会显示在搜索引擎结果中。

    • 308 Redirect/Rewrite: for permanent redirections of existing dynamic pages. The URL is renamed; the new name is shown in search engine results and is cached by browsers. Use this redirect type to rename a dynamic page, for example, if you wish to rename /shop into /market.

  • URL from: Enter the URL to be redirected (e.g., /about-the-company) or search for the desired dynamic page and select it from the list.

  • URL to: For 301, 302, and 308 redirects, enter the URL to be redirected to. If you want to redirect to an external URL, include the protocol (e.g., https://).

  • 网站:选择特定网站。

  • Sequence: To define the order in which redirections are performed, e.g., in the case of redirect chains (i.e., a series of redirects where one URL is redirected to another one, which is itself further redirected to another URL).

Toggle the Activate switch to deactivate the redirection.

重要

404, 301, and 302 redirections are meant to migrate traffic from unpublished or deleted pages to new pages, while the 308 redirect is used for permanent redirections of existing pages.