Jump to content

title meta tag


Marudor
 Share

Recommended Posts

take the seo_title when it isn't empty, else take the page title:

<?php $pagetitle = $page->seo_title ?: $page->title; ?>
<title><?= $pagetitle ?></title>

You could do the same with the meta description. Take the seo_description if it isn't empty, else make a shortened version of your bodytext limited 156 characters.

Link to comment
Share on other sites

You can use the pipe character too. I use this:

<meta name="description" content="<?php if ($page->metaDescription) {echo $page->metaDescription;} ?>">
<title><?= $page->get("windowTitle|headingSubtitle"); ?></title>

I use field 'windowTitle' to specifically change the main title for each page individually for SEO purposes. If not present or present but blank, use 'headingSubtitle' field.

  • Like 1
Link to comment
Share on other sites

1 hour ago, SamC said:

You can use the pipe character too. I use this:


<meta name="description" content="<?php if ($page->metaDescription) {echo $page->metaDescription;} ?>">
<title><?= $page->get("windowTitle|headingSubtitle"); ?></title>

I use field 'windowTitle' to specifically change the main title for each page individually for SEO purposes. If not present or present but blank, use 'headingSubtitle' field.

Thanks for You answers, but processwire is new to me ( I was working before on Wordpress) . Do I have to create a new field in edit template ?

Where would I add that code.  I have an acces to the serwer if it's not possible through the admin panel.

http://www.qacommunications.com/pl/case-study/employer-branding-pracownik-staje-sie-klientem/

Link to comment
Share on other sites

6 minutes ago, Marudor said:

Do I have to create a new field in edit template ?

All done in admin area. In my example, the fields are:

metaDescription (text area)
windowTitle (text field)
headingSubtitle (text area)

Create them at admin > setup > fields.

Add to template at admin > setup > templates (for example, edit 'basic-page' template and add fields).

Edit/create page with 'basic-page' template. Fields will be there now.

Output on webpage via template file located at '/site/templates/basic-page.php'.

Of course this applies to any templates you like and can structure them as you wish.

I prefer to use something like the second code block in this example but there are other approaches, experiment a bit:

Hope this helps :)

Link to comment
Share on other sites

You need to add the field to the template which was used to create the case study page.

On the page edit, can see settings tab. That will show you which template is being used.

Details/input/actions are for specific settings on a field.

The code will go in the template file i.e. /site/templates/basic-page.php or wherever your head section is rendered from. Maybe '_main.php'? It depends on your approach to organzing your templates.

  • Like 2
Link to comment
Share on other sites

28 minutes ago, Marudor said:

Will Markup SEO work for ProcessWire 2.7.3 ...is it safe to install ?

And will it do the trick of adding the field for title tag?

I'm not sure we're on the same wavelength here. What do you need the module for?

Every page has a title field, it's mandatory. You name the page anything you want when you you create it (you can edit it anytime too) and will be unique for each new page you create (because it wont allow duplicates).

For example, I could create a template called 'about'. Then create a page called 'About me' using the 'about' template. That page has a title field which I could fill in with 'This page is about me'. Publish it and then you can output the field like so in a file '/site/templates/about.php':

<html>
  <head>
	<title><?= $page->title; ?></title>
  </head>
  <body>
    STUFF
  </body>
</html>

So at 'yoursite.com/about-me/' you would get:

<html>
  <head>
	<title>This page is about me</title>
  </head>
  <body>
    STUFF
  </body>
</html>

Are we even talking about the same thing? :huh:

 

Link to comment
Share on other sites

Meta tag title is not allways the same as title.

here

http://www.qacommunications.com/pl/case-study/employer-branding-pracownik-staje-sie-klientem/

The title is Employer branding - pracownik staje się klientem

And the Meta title tag is Employer branding - pracownik staje się klientem - Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol   .........which is too long

The processwire is adding automatically - Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol   

I want to set up a title tag manualy for each page  for SEO reasons.

Link to comment
Share on other sites

Processwire doesn't automatically add anything, It's up to the designer/developer what text is output. That said:

1 hour ago, Marudor said:

I want to set up a title tag manualy for each page  for SEO reasons.

I've already described how to do this earlier.

I think you're possibly not fully understanding how the templates/fields work together yet because what you're trying to do is pretty simple once you get the hang of these concepts, you certainly don't need a module here.

Could you post the code from your template that outputs the <HEAD> section of that page and we can sort something out :)

Link to comment
Share on other sites

I don't understand how they work that's true,  that's why I am asking for tips. Yesterday I have seen the processwire for the first time, and it's very much differnt from wordpress where everything is simple. I was asked to optimize the text and correct the meta tags for this page and I am indded having a problems with this title tag. 

 

Link to comment
Share on other sites

@Marudor

Hi, I recommend reading a few tutos, like:

5 hours ago, Marudor said:

Will Markup SEO work for ProcessWire 2.7.3 ...is it safe to install ?

It should work but it will not affect the frontend of the site because in ProcessWire nothing is outputted without writing some code in the template files. There is no "theme" in the WordPress sense.

35 minutes ago, Marudor said:

I was asked to optimize the text and correct the meta tags for this page

You need to start taking a look at the template file(s) rendering the page(s) to get started. The developer who implemented the forntend could have chosen all sorts of ways to do it, but if you can provide some code samples we can help by pointing you in the right direction.

As you can also see in the tutorials linked above, you need to look for something like (but not the same...): 

<title><?php echo $page->title; ?></title>

And there must be some concatenation used too which adds  "Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol" to the string.

4 hours ago, Marudor said:

I want to set up a title tag manualy for each page  for SEO reasons.

You can do it this way:

<title><?php echo $page->my_field_goes_here; ?></title>

where my_field_goes_here is the name of the field you need to add to the template(s) of the page(s). That is where Markup SEO can help you but I never used that module. However, the site might use a template engine like Twig or something similar, so you might not see regular PHP echos being used and that is why you need to find out what renders what in the fist place.

  • Like 1
Link to comment
Share on other sites

1 hour ago, Marudor said:

I don't understand how they work that's true,  that's why I am asking for tips. Yesterday I have seen the processwire for the first time, and it's very much differnt from wordpress where everything is simple.

Just to clarify, what I said was not intended as an insult, far from it. I meant with some more learning, you'll be able to do this stuff no problems.

I come from the othet direction in that wordpress makes no sense to me but a 'proper' CMS does. I mean proper by one with custom fields, templates etc... out the box.

Like I said, posting the code you have that renders your head section (or the entire template) would be extremely useful here.

  • Like 1
Link to comment
Share on other sites

22 hours ago, SamC said:

Just to clarify, what I said was not intended as an insult, far from it. I meant with some more learning, you'll be able to do this stuff no problems.

I come from the othet direction in that wordpress makes no sense to me but a 'proper' CMS does. I mean proper by one with custom fields, templates etc... out the box.

Like I said, posting the code you have that renders your head section (or the entire template) would be extremely useful here.

hmm. I had very little time to read this tutorial, Is it possible to do it without knowledge of php. I know only basic html and that's enough for wordpress to create nice websites..... it seems like it's not enough here.  Where can i find that code You are talking about? Is it It in the admin panel or in some folder on the server ? Person who was a developer of that site changed the job , and there's noone whoo can do it in the firm.  I just want to make the meta tags right it should not be that compilacated. 

Link to comment
Share on other sites

The code is in a template file. We can't tell you which one because you can set up processwire according to your own preferences.

If it's a live site then the files will be on the server yes.

Template files go in '/site/templates/' so you need to start by looking in that folder.

You're only looking for the file that contains the code that ouputs the <head> section of your site, that's where the meta (and title) tags go.

It might be '/site/templates/_main.php' or '/site/templates/header.php' or '/site/templates/includes/header.php/'.

See the problem? We can't guess as there's not a 'correct' or single way to organize processwire. This is one reason why I use it over any other CMS I've tried.

If you're willing to learn, then with your current skillset, I think you'd go further with processwire. However, of you mean 'nice websites' by copy/paste then wordpress would work better for you simply because there are 1000s of code examples.

  • Like 1
Link to comment
Share on other sites

23 minutes ago, SamC said:

The code is in a template file. We can't tell you which one because you can set up processwire according to your own preferences.

If it's a live site then the files will be on the server yes.

Template files go in '/site/templates/' so you need to start by looking in that folder.

You're only looking for the file that contains the code that ouputs the <head> section of your site, that's where the meta (and title) tags go.

It might be '/site/templates/_main.php' or '/site/templates/header.php' or '/site/templates/includes/header.php/'.

See the problem? We can't guess as there's not a 'correct' or single way to organize processwire. This is one reason why I use it over any other CMS I've tried.

If you're willing to learn, then with your current skillset, I think you'd go further with processwire. However, of you mean 'nice websites' by copy/paste then wordpress would work better for you simply because there are 1000s of code examples.

The only code with head section is in blog-main.inc , there is a bit with title tag bit:

    <!doctype html>
    <html lang="pl" xmlns="http://www.w3.org/1999/html">
        <head>

            <meta charset="UTF-8"/>

    <title><?php if($page->id > 1) { echo $page->title .' - '; } echo $home->title ?></title>

    <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates; ?>css/main.css?4"/>
    <link rel="stylesheet" type="text/css" href="<?php echo $config->urls->templates; ?>css/page.css?4"/>
    <link rel="stylesheet" href="<?php echo $config->urls->templates; ?>vendor/magnific-popup/magnific-popup.css">
    <link rel="stylesheet" href="<?php echo $config->urls->templates; ?>vendor/owl-carousel/owl.carousel.css">
    <link rel="stylesheet" href="<?php echo $config->urls->templates; ?>vendor/owl-carousel/owl.theme.css">
    <link href="<?php echo $config->urls->templates; ?>vendor/custom-scrollbar-plugin/jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" />

    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>

    <meta name="description" content="<?php echo (strlen($page->meta_description) > 0) ? $page->meta_description : $configuration->meta_description ; ?>">
    <meta name="keywords" content="<?php echo (strlen($page->meta_keywords) > 0) ? $page->meta_keywords : $configuration->meta_keywords; ?>">
    <meta name="robots" content="NOODP">
    <link href="<?php echo $config->urls->templates; ?>vendor/bxslider/jquery.bxslider.css" rel="stylesheet"/>

    <base href="<?php echo $config->urls->root; ?>">

    <script>
        var URL = "<?php echo $config->urls->root; ?>";
    </script>

 

Would I change <title><?php if($page->id > 1) { echo $page->title .' - '; } echo $home->title ?></title> 

for 

<title><?= $page->get("windowTitle|headingSubtitle"); ?></title>

   I dont want to blow the site....is there any risk 

Link to comment
Share on other sites

Just so you know, this one appends homepage title to all pages (except homepage, of course), so you get `My Page Title - MySite`

<title><?php if($page->id > 1) { echo $page->title .' - '; } echo $home->title ?></title>

This one changes it into just `My Page Title` (without the suffix)

<title><?= $page->get("windowTitle|headingSubtitle"); ?></title> 

and yes it should work without any issues

I wasn't really following the previous discussion. See @SamC's comment below

Link to comment
Share on other sites

41 minutes ago, Marudor said:

Would I change <title><?php if($page->id > 1) { echo $page->title .' - '; } echo $home->title ?></title> 

for 

<title><?= $page->get("windowTitle|headingSubtitle"); ?></title>

   I dont want to blow the site....is there any risk 

No don't do that. 'windowTitle' and 'headingSubtitle' are fields I created on MY own site. You more than likely don't have these fields.

Whats happening is this (as per your example earlier):

<title>
  <?php
    // any page OTHER THAN the home page
    if($page->id > 1) {
      // prints 'Employer branding - pracownik staje się klientem -'
      echo $page->title .' - ';
    }
    // prints 'Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol'
    echo $home->title
  ?>
</title> 

So that bit of code outputs:

Employer branding - pracownik staje się klientem - Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol

...which is what you are seeing and you referred to it as:

On 18/10/2017 at 3:55 PM, Marudor said:

The processwire is adding automatically - Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol   

If you just want the first bit, then you just need:

<title><?php echo $page->title; ?></title>

I'm not even sure if you can log into the admin on your site? If you can, you will see the 'Title' field on each page if you edit it.

1.thumb.png.23bab8f0ce83eaee5dc752e42b3c7da9.png

Browsing your site, look at the page titles and you'll see what's happening:

http://www.qacommunications.com/ 
(Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol)

http://www.qacommunications.com/pl/kariera/
(Dołącz do nas! - Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol)

http://www.qacommunications.com/pl/zakres-dzialan/
(Zakres działań - Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol)

http://www.qacommunications.com/pl/biuro-prasowe/
(Klienci - Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol)

 

See what the code is doing now?

'Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol' is the 'Title' field of your homepage. This is being appended to every other page title on every page other than the homepage.

  • Like 2
Link to comment
Share on other sites

12 hours ago, SamC said:

I'm not even sure if you can log into the admin on your site? If you can, you will see the 'Title' field on each page if you edit it.

I do have an acces to the admin panel. 

That's what I'm talkin about, I want to have the meta tag without the added suffix ( Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol that comes from the home page. 

How can I change it just on one page

Not on every page. Later if it will work I would change the title meta tag for other pages manually.

Can I find that code and just cancel   Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol

<title>Employer branding - pracownik staje się klientem - Agencja PR Q&A Communications – Poznań, Gdańsk, Warszawa, Bristol</title>

2017-10-20_110406.thumb.jpg.32c249df1ad24dcf67499c0d061ea417.jpg

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...