页面

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

注解

*静态*页面是指内容稳定的页面,如主页。您可以手动创建新页面,定义其 URL,调整其 属性 等。另一方面,*动态*页面是动态生成的。所有由 Odoo 自动生成的页面,例如当您安装应用程序或模块(如 /shop`或/blog`)或发布新产品或博文时生成的页面,都是动态页面,因此管理方式不同。

页面创建

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

    • 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, as well as in 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.

页面管理

发布/取消发布页面

页面需要发布才能让网站访客访问。要发布或取消发布页面,请访问该页面,然后切换右上角的开关,从 未发布 切换到 已发布,反之亦然。

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.

主页

默认情况下,当您创建一个网站时,Odoo 会创建一个专门的 主页 页面,但您可以定义任何网站页面作为您的主页。为此,请进入 网站‣ 配置‣ 设置,然后在 :guilabel:` 网站信息` 部分,在 :guilabel:` 主页 URL` 字段中定义所需页面的 URL(例如,/shop)。

或者,您也可以进入 网站 ‣ 站点 ‣ 属性,将任何静态页面定义为主页。选择 发布 选项卡并启用 用作主页

页面属性

要修改静态页面的属性,请访问要修改的页面,然后转到 站点 ‣ 属性

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 重定向

Redirecting URLs consists in sending visitors and search engines to a URL that is different from the one they originally requested. This technique is used, for example, to prevent broken links when you delete a page, modify its URL, or move your site to a new 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.

注解

  • A record is added automatically every time you modify a page’s URL and enable Redirect Old URL.

  • You can set up redirections for static and dynamic pages.

To create a new redirection, click the New button, then fill in the fields:

  • Name: Enter a name to identify the redirect.

  • Action: Select the type of redirection:

    • 404 未找到页面:访问者在尝试访问页面时会被重定向到 404 错误页面。

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

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

    • 308 重定向/重写:用于动态页面的永久重定向;新 URL 会显示在搜索引擎结果中,重定向会被浏览器缓存。使用此重定向类型可重命名动态页面,例如,将 /shop`重命名为 `/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, make sure to 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 only work if the original page has been unpublished or deleted.