/    Sign up×
Community /Pin to ProfileBookmark

Changing Same Elements across all HTML documents

Is there a faster way to change something across all html documents? For example, I wanted to change the <title> description on my index page and my 7 other pages. Manually doing so isn’t that difficult but it seems that it’d be tedious to do it if there were at least 100 html docs of that website. There’s gotta be an easier way. I use sublimetext2 as my editor in case that helps anyone.

to post a comment
HTML

3 Comments(s)

Copy linkTweet thisAlerts:
@auntniniJul 07.2015 — As an "automated manual" operation, you could try to "find/replace" text.

With Dreamweaver, I first COPY (cmd/ctrl-C) existing text, then press ctrl-F (for FIND) dialog box, where I can enter REPLACE WITH text or nothing to delete.
Copy linkTweet thisAlerts:
@Isabella_martinJul 08.2015 — If you want to do so then you have to work on server side scripting languages. You can change the title of each web page by passing the title from server side language. In this way you dont need to change the title on each page.

In simple words you have to develop a dynamic website.
Copy linkTweet thisAlerts:
@jedaisoulJul 08.2015 — Just to clarify:

- Yes, you can use PHP include files to hold the common content of the web pages. This allows you to edit once and change all.

- No, this does not make the web pages "dynamic". That term means that the data is stored in a database, which is not the case with include files.

I use PHP include files all the time to contain the header, footer, navbar etc... It has the additional benefit that these elements are cached on the server, so are not re-read for every web page, which speeds up the page load (after the first one).

However, some things you need to know:

  • 1. You need to rename your web pages with the fie extension .PHP instead of .HTML. Note: This is not strictly necessary, but if you are a beginner with PHP it is the simplest way of telling the server that the file contains PHP code.


  • 2.You can't just test your source files with a browser (as you can with HTML files). Rather, you need to set up a local host on your PC and develop on that. Fortunately, this is very easy to do. Just download Wampserver (Windows) or xampp (Linux) and install. The installation of Wampserver is completely automated (I haven't tried xampp). All you need to do is move your development area to C:wampwww (or wherever you have installed it), and work there.

  • 3. It is very easy to set up PHP include files:

    a) Rename yur .HTML files to .PHP.

    b) Identify the block(s) of code that are common across multiple web pages.

    c) Copy each block to a separate file, e.g. "header.inc". Note: You can use any file extension you like, I have just used ".inc" because that seems logical to me.

    d) Replace each block of code in the PHP files with:
    <i>
    </i>&lt;?php include "include-file-name" ?&gt;

    E.g.
    <i>
    </i>&lt;?php include "header.inc" ?&gt;


  • 4. You can run your code by using a shortcut with the target "http://localhost/page-name.php" (substitute you web page's name for "page-name").
  • ×

    Success!

    Help @jzhang172 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 5.27,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,
    )...