当前位置: 首页 > 网络学院 > 设计教程 > 设计理念 > 网站维护的简单方法

设计理念
网站设计DIY
网站字体应该具有视觉吸引力
网站设计中出现的新问题
创建Flash导航菜单
网站设计的几个主要方面
易于浏览的网页可以增加销售量
网站应该能够增加销售量
高质量的网站设计
提高网页下载速度
合理设计网站
网站营销中容易出现的错误
设计有特色的网站
如何设计有价值的logo
网站设计团队应该具备的9个因素
网站维护的简单方法
网络安全字体
创建有效网站的5条建议
网站设计避免出现8大错误
成功进行外包业务的10条建议
网站设计应该追求简约

设计理念 中的 网站维护的简单方法


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 1441 ::
收藏到网摘: n/a

Before building a site, every webmaster has to make a decision on what layout method to use. Most seem to go with either a frame or a table-based layout, the latter being more popular in these days.

网站构建之前,每一个网站管理员都需要决定布局方法。大多数网站管理员会选择框架或表格,其中后者应用更广泛。

While both of these have their advantages and disadvantages, a frame-based site is usually easier to update. If you happen to have a 200-page site with the same navigation on every page, adding one link to the navigation menu might require you to edit all of the pages if the design is built with tables. On the other hand, if the site uses frames, you can get by with changing just a few files and save yourself a lot of time.

这两种布局方法各有自己的优缺点,框架网站通常更容易下载。如果表格网站包含200张网页,所有网页导航系统相同,现在希望在导航菜单中添加一个链接,你可能需要重新编辑所有网页。然而,如果是框架网站,你只需要更改几个文件,会节省很多时间。

No, I'm not trying to convince you to switch to frames. I myself use tables and am not going to change my layout. The only problem is that over time, sites tend to grow. It just might be possible to edit around 20 pages when you want to change something, but when we start talking 50 or over one hundred, it just doesn't seem like a good idea. Unless you are prepared to spend hours trying to keep your navigation menu up to date, you have to come up with a better way of doing things.

我并不是希望你利用框架进行网站布局,我的网站就是表格网站,并且我也不会更改这个布局。现在的问题是,网站以后需要不断添加内容,虽然我们可能会逐一编辑20张网页,但如果网页为50或者100多张,这个方法就不可行了。你需要寻找一个更好的网页更新办法,除非你有很多时间。

Using_SSIs_To_Ease_Site_Maintenance

SSI's to the Rescue
利用SSI's解决问题

If your host supports Server Side Includes and is running Apache, you can use this article to make your table design as easy to maintain as it would be if you were using frames. The best part is that visitors won't even notice that you have changed anything. After the new system is in place, they will see exactly the same design and HTML code as before, but you will be saved from hours of monotonous work.

如果网站虚拟主机支持Server Side Includes(服务器端包含),并且Apache可以运行,你可以参考这篇文章,方便地进行表格网站与框架网站的维护。最好的一点是,访问者不会察觉网站的修改,新系统建立以后,访问者会看到与以前相似的设计与HTML编码,但你可以节省大量工作、大量时间。

Server Side Includes, or SSI's, can be used in many ways. With them you can execute CGI programs, display the current date & time on your page and do plenty of other things as well. In this article, we use them for including external files to your HTML. The idea is to create a separate file from your navigation menu and use SSI's to point to it, requiring you to merely edit one file when you wish to change the navigation.

SSI's
的用途很多,利用它,你可以运行CGI程序、在网页中显示当前时间与日期,还可以完成其它很多工作。这篇文章中,我们会介绍利用SSI's,把外部文件存储器纳入HTML中,这样可以创建一个独立于导航菜单的文件,利用SSI's进行编辑,这样在修改导航系统时,只需要编辑一个文件。

Should you have some knowledge of Server Side Includes, you might be a little worried. Doesn't this require that you rename all your pages from ".html" to ".shtml" if you want it to work? That would take a lot of time, break the links that are pointing to your site and you might have to resubmit your pages to the search engines. Is it reasonable to go through all that trouble to make maintaining your site a little easier?

如果不具备SSI's知识,你可能会有点担心:如果这样,网页名称需要由".html"改变为".shtml"吗?这样需要很多时间,并且会断开与网站的链接,你需要重新向搜索引擎递交网页。有没有可能避免这些麻烦,更方便地维护网站呢?

Fortunately, there's no need to start renaming any files. You can simply instruct the server to treat your ".html" files as ".shtml" files and execute all SSI instructions in them. This can be done with a ".htaccess" file. If you already have one, you'll have to edit it. If you don't, open up a text editor, such as Notepad, and paste the following lines into a blank file. Be sure to replace .html with .htm, if you're using that extension.

很幸运的是,我们不需要改变文件名称,你只需要命令服务器把".html"文件当成".shtml"文件,并且在文件中执行SSI指令就可以了。这个过程在".htaccess"文件中可以完成,如果已经具备此文件,你需要进行编辑;如果没有,打开文本编辑器,比如说,记事本,把以下内容粘贴到空白文件中,如果运用这个扩展名,确保用.htm替代.html
Options Includes
AddType text/html .html
AddHandler server-parsed .html

Save the file in "All files" mode and name it ".htaccess". Include the quotes so that Notepad won't decide to name the file ".htaccess.txt".

 
在“All files(所有文件)”状态下保存为".htaccess"文件,文件名称包含引号,这样记事本不会把文件命名为".htaccess.txt"

Changing Your Pages
更改网页

After the .htaccess file has been created, you'll have to make changes to your HTML files. To be on the safe side, take backups of them before doing anything. Then, paste the HTML you use to generate the menu from one of your pages into a blank file. Save the file as "navig.html" for example. Next, remove the navigation menu from all of your pages. Replace it with the following line:

.htaccess
文件建立以后,你需要修改HTML文件。在修改以前,首先进行文件备份,然后,把生成菜单的HTML从一张网页粘贴到空白文件中,比如说,可以保存为"navig.html"文件。下一步,更换所有网页的导航菜单,利用以下符号代替:
<!--#include file="navig.html" -->

What you're doing is telling the server to insert the code from "navig.html" into the page. This will be done before the page is sent to the user who has requested it, so anyone visiting your site will merely see a normal HTML file. When you have finished editing your files, connect to your host via FTP and upload the ".htaccess" file, the "navig.html" file and the new versions of your content pages.

你只是告诉服务器插入编码(从"navig.html"文件到网页),这个过程在网页呈现给用户之前就已经完成,所以访问者只会看到普通的HTML文件。文件编辑完成之后,通过FTP".htaccess"文件、"navig.html"文件以及更新后的网页上传到虚拟主机中。

Then it is time for the true test, trying to visit your site and see what happens. If you have done everything correctly, you should see that your pages look the same as before. However, if you make a simple change to the "navig.html" file, it will apply to the navigation menu of every page. What used to take minutes or even hours can now be done in seconds, giving you the possibility to use that valuable time to do something other than changing the HTML code of each page separately.

现在,需要进行测试,浏览网站,查看是否存在问题,如果没有问题,观察网页外观是否与以前相同。如果对"navig.html"文件做过修改,所有网页导航菜单都会发生变化。利用SSI's以后,以前需要花费几分钟甚至几小时的工作,现在只需几秒钟就可以完成了,我们可以利用这些时间完成其它工作,确实有意义。

评论 (1) 1 All

登陆 | 还没注册?