HTML 中使用什么来代替框架

发布于 2024-10-08 19:09:13 字数 144 浏览 10 评论 0原文

我需要用 HTML 构建一个网站。我需要每个页面的顶部看起来都一样(我通常使用 ASP.NET 母版页)。有什么方法可以避免使用相同的标题和导航,而无需在每个页面顶部使用相同的代码?

该网站需要对 SEO 友好,所以我宁愿不使用框架。

谢谢。

I need to build a site in HTML. I need the top of every page to look the same (I normally use ASP.NET master pages). Is there any way I can get around having the same header and navigation without having the same code at the top of every page?

The site need to be SEO friendly so I would rather not use frames.

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

眉黛浅 2024-10-15 19:09:13

无论如何,我可以避免必须具有相同的标题和导航,而不必在每个页面的顶部具有相同的代码。

并非没有与使用框架相同或相似的缺点。

如果您想要一个不依赖于服务器端支持的模板机制,请查看Template-Toolkit。它有一个名为 ttree 的实用程序,它将根据您的数据构建一组静态文件然后您可以将模板上传到没有 SSI、PHP、母版页等内容的主机。

Is there anyway I can get around having to have the same header and navigation without having to have to have the same code at the top of every page.

Not without having the same, or similar, drawbacks as using frames.

If you want a template mechanism that doesn't depend on server side support, check out Template-Toolkit. It has a utility called ttree that will build a set of static files from your data and templates which you can then upload to hosting which doesn't have anything like SSI, PHP, Masterpages, etc.

你是年少的欢喜 2024-10-15 19:09:13

您可以在部署网站之前“编译”网站。因此,您可以将页面编写为包含标头的 PHP 脚本,然后通过运行脚本并部署其输出来“编译”它们。

You could kind of "compile" the website before deploying it. So, you could write the pages as PHP scripts that include the header and then "compile" them by running the scripts and deploying their outputs.

幼儿园老大 2024-10-15 19:09:13

我不是 HTML 专家,但是,我确信可以创建浮动层(使用

部分)可以停靠在页面顶部

I'm not a HTML guru, however, I'm sure that it is possible to create a floating layer (using <DIV> or <SPAN> sections) that could be docked at the top of the page

这个俗人 2024-10-15 19:09:13

大多数网站都是使用某种描述的网络框架构建的。这些本质上允许您为站点页面定义模板 - 例如,您可以定义页眉、页脚、菜单等,框架将在渲染时(请求页面时)将其插入到您的页面中。然而,此类页面是“动态的”,因此需要脚本环境(例如 perl、python、ruby、php)才能生成请求的页面。有许多适用于这些语言的框架;或者,如果您正在构建一个超级简单的网站,您可以设置自己的模板并使用它们。

但是,如果您仅限于纯 HTML(即静态页面),那么如果您想避免框架,则必须手动将通用 HTML 添加到每个页面。

Most sites are built using a web framework of some description. These essentially allow you to define templates for your site pages - e.g you can define headers, footers, menus etc which the framework will insert into your page at render time (when the page is requested). However such pages are "dynamic" and thus require a scripting environment such as perl, python, ruby, php in order to generate the requested page. There are many frameworks available for these languages; or if you're building a super simple site you could set up your own templates and use those.

If however you're limited to pure HTML, i.e static pages, then yes you're going to have to manually add the common HTML to each page if you want to avoid frames.

微凉 2024-10-15 19:09:13

作为一般方法,您通常将页眉(实际上还有页脚、其他常见页面部分等)存储在单独的文件中,并将这些文件包含在每个页面上。根据平台的功能,您甚至可以使这些文件变得智能,即它们可以根据“当前”URL 进行自我更改。

通过使用这种方法,您的好处是只需在一个文件中编辑“标题”等,而不必搜索和查找文件。替换整个站点,或者(更糟糕的是)手动在每个页面上进行更改。

然而,如果不知道您正在使用什么平台(ASP.NET/MVC、PHP、JSP 等),就不可能推荐任何特定的平台。

As a general approach, you'd usually store the header (and indeed footer, other common page sections, etc.) in a separate file and include these files on each page. Depending on the capabilities of the platform, you could even make these files intelligent, in the sense that they could alter themselves based on the "current" URL.

By using this approach, you have the benefit of only having to edit the "header", etc. in one file rather than having to search & replace across the entire site, or (worse still) manually carry out the changes on every page.

However, without know what platform you're using (ASP.NET/MVC, PHP, JSP, etc.) it's impossible to recommend anything specific.

夏至、离别 2024-10-15 19:09:13

您可以使用服务器端包含并将页面分为页眉页、侧导航页和页脚页。

然后您可以将它们作为服务器端包含在每个页面中。

You could use server-side includes and break the page up into Header pages, Side navigation pages and footer pages.

Then you can include these as server-side includes in each of your pages.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文