页面

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

Static pages, such as the homepage or any custom-created, contain fixed content that does not change dynamically. You can manually create these pages, define their URLs, and adapt their properties as needed. 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. In the New Page selection menu, click on a template. They are sorted by type:

    • Basic: Multi-purpose page. A blank page is also available to start from scratch.

    • About: Information about your brand.

    • Landing Pages: Summary of company content and info.

    • Gallery: Photos and media showcase.

    • Services: Focus on what you’re selling and contact.

    • Pricing Plans: Highlight on subscription and prices.

    • 团队:您公司背后的团队。

    • 自定义:选择自定义模板。要在此类别中添加模板,请打开要保存为模板的页面,然后转到 站点 ‣ 属性,输入 页面标题编辑页面属性,启用 是模板,然后点击 保存

  2. 输入 页面标题 ;该标题将用于菜单和页面的 URL。

  3. 点击:guilabel:创建

  4. 如果需要,请使用网站编辑器 自定义页面的内容和外观,然后点击 保存

  5. :ref:`发布 <website/pages/un-publish-page>`页面。

小技巧

如果页面不应出现在菜单中,则禁用 添加到菜单

页面管理

发布/取消发布页面

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

Unpublished/Published toggle

注解

也有可能:

  • 从 :ref:`页面属性 <website/pages/page_properties>`中发布/取消发布页面,您可以在其中定义发布日期和/或根据需要限制页面的可见性;

  • 同时发布/取消发布多个页面:进入 网站 ‣ 站点 ‣ 页面,选择页面,然后点击 操作 并选择 发布`或 :guilabel:`未发布

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

页面属性

要修改 静态页面的 属性,请访问要修改的页面,然后转到 站点 ‣ 属性,在这里可以修改以下属性:

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

    • 301 Moved permanently: to redirect the page permanently.

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

    重定向旧 URL
  • In Menu: Disable if you don’t want the page to appear in the menu.

  • Is Homepage: Enable if you want the page to be the homepage of your website.

  • Published: Enable to publish the page.

  • Publishing Date: To publish the page at a specific date and time, click the field, set the date and time, then press Enter or click Apply to validate your selection.

  • Indexed: Disable if you don’t want the page to appear in search engine results.

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

    • Public: Everyone can access the page.

    • Signed In: Only signed-in users can access the page.

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

    • With Password: Type the password required to access the page in the Password field.

  • Is a template: Toggle the switch to save the page as a template and add it to the Custom category.

小技巧

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

复制页面

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

删除网页

删除页面的步骤如下:

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

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

  3. 更新链接(或设置 重定向)后,勾选 我确信 复选框,然后点击 确认

URL 重定向映射

URL 重定向映射包括将访问者和搜索引擎发送到与他们最初请求的不同的 URL。例如,当您 删除一个页面, 修改其 URL, 或将您的网站从另一个平台迁移到 Odoo :doc:` 域 <configuration/domain_names>`时,这种技术用于防止链接中断。它也可以用来改进 Search Engine Optimization (SEO)

要访问现有的 URL 重定向并创建新的 URL 重定向,请 激活开发者模式 并转到 网站 ‣ 配置 ‣ 重定向

注解

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

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

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

    • 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, 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.