转换大型网页组的最佳方法是什么?

时间:2021-06-24 20:08:50

What is the best way to transform large bunches of very similar web pages into a newer css-based layout programatically?

以编程方式将大量非常相似的网页转换为更新的基于CSS的布局的最佳方法是什么?

I am changing all the contents of an old website into a new css-based layout. Many of the pages are very similar, and I want to be able to automate the process.

我正在将旧网站的所有内容更改为新的基于CSS的布局。许多页面非常相似,我希望能够自动化该过程。

What I am currently thinking of doing is to read the pages in using HtmlAgilityPack, and make a method for each group of similar pages that will create the output text.

我目前正在考虑做的是使用HtmlAgilityPack读取页面,并为将创建输出文本的每组相似页面创建一个方法。

What do you think is the best way to do this? The pages mostly differ by things like which .jpg file is used for the image, or how many groups of heading-image-text there are on that particular page

您认为最好的方法是什么?这些页面大多不同于.jpg文件用于图像,或者该特定页面上有多少组标题图像文本

EDIT: I cannot use any other file type than .html, as that is all I am authorized to do. Any suggestions?

编辑:我不能使用除.html之外的任何其他文件类型,因为这是我有权做的。有什么建议?

EDIT2: Ideally, I would also be able to make this be generic enough that I could use it for many different groups of html files by just switching around a few moving parts.

编辑2:理想情况下,我也可以使它足够通用,我可以通过切换几个移动部件将它用于许多不同的html文件组。

2 个解决方案

#1


Sounds like you should be re-using code. If you are using strictly HTML, I would consider doing PHP or ASP based webpages instead. That way, you can create Header/Content/Footer/Nav sections, and re-use the same code across all your webpages.

听起来你应该重用代码。如果您使用严格的HTML,我会考虑改为使用基于PHP或ASP的网页。这样,您就可以创建页眉/内容/页脚/导航部分,并在所有网页上重复使用相同的代码。

This would make it a lot more sustainable, as you would only need to edit one file in the future.

这将使其更具可持续性,因为您将来只需要编辑一个文件。

#2


What about using Server Side Includes (SSI) <#!--#INCLUDE -->

那么使用服务器端包含(SSI)<#! - #INCLUDE - >

This was you can create different parts of your webpage in different files and just "include" them in any other page you want.

这是您可以在不同的文件中创建网页的不同部分,只需将它们“包含”在您想要的任何其他页面中。

header.html body.html footer.html

header.html body.html footer.html

<html>
<!--#INCLUDE file="header.html" -->
<!--#INCLUDE file="body.html" -->
<!--#INCLUDE file="footer.html" -->
</html>

More info here

更多信息在这里

#1


Sounds like you should be re-using code. If you are using strictly HTML, I would consider doing PHP or ASP based webpages instead. That way, you can create Header/Content/Footer/Nav sections, and re-use the same code across all your webpages.

听起来你应该重用代码。如果您使用严格的HTML,我会考虑改为使用基于PHP或ASP的网页。这样,您就可以创建页眉/内容/页脚/导航部分,并在所有网页上重复使用相同的代码。

This would make it a lot more sustainable, as you would only need to edit one file in the future.

这将使其更具可持续性,因为您将来只需要编辑一个文件。

#2


What about using Server Side Includes (SSI) <#!--#INCLUDE -->

那么使用服务器端包含(SSI)<#! - #INCLUDE - >

This was you can create different parts of your webpage in different files and just "include" them in any other page you want.

这是您可以在不同的文件中创建网页的不同部分,只需将它们“包含”在您想要的任何其他页面中。

header.html body.html footer.html

header.html body.html footer.html

<html>
<!--#INCLUDE file="header.html" -->
<!--#INCLUDE file="body.html" -->
<!--#INCLUDE file="footer.html" -->
</html>

More info here

更多信息在这里