How can I change the number of items in a view only for the first page? I'm trying to build a view with a different number of items for the first page (2 items) than the others (3 items). How can I build it to avoid skipping items ?
I made tests using hook_views_pre_build() but the result isn't conclusive as the second page will miss one item (item C):

Here is my current code:

function MYMODULE_views_pre_build(&amp;$view) {
  if ($view-&gt;name == 'my_view' &amp;&amp; empty($_GET['page']) {
    //The view normally has 3 items per page, put 2 for the first page.
    $view-&gt;items_per_page = 2;
  }
}


And here is the result I obtain:


  First page:
  
  
  item A
  item B
  
  
  Second page:
  
  
  item D
  item E
  item F
  


As you can see, item C is missing because setting the number of items per page to 3 imply that the first page also has 3 items.

Is there another way to get this working ?
This is how I got it working, use two hooks. Assuming we have a view called my_view and the display is page_1.
Pre-build: Set the items per page to 10 for the first page.
Pre-render: Add an additional CSS class to the view.
/**
 * Implements hook_views_pre_build().
 */
function my_module_views_pre_build(ViewExecutable $view) {
  if ($view-&gt;id() === 'my_view' &amp;&amp; $view-&gt;current_display === 'page_1') {
    // Page is zero indexed: first page is NULL or 0.
    if (!$view-&gt;getRequest()-&gt;query-&gt;get('page')) {
      // Default is 9, we set it to 10.
      $view-&gt;setItemsPerPage(10);
    }
    else {
      // Set the offset on subsequent pages, because we have one more on the first page.
      $view-&gt;setOffset(1);
    }
  }
}

/**
 * Implements hook_views_pre_render().
 */
function my_module_views_pre_render(ViewExecutable $view) {
  if ($view-&gt;id() === 'my_view' &amp;&amp; $view-&gt;current_display === 'page_1' &amp;&amp; !$view-&gt;getCurrentPage()) {
    // Add CSS class for first page.
    $view-&gt;display_handler-&gt;setOption(
      'css_class',
      $view-&gt;display_handler-&gt;getOption('css_class') . ' is-first-page'
    );

    // To attach a library, use:
    // $view-&gt;element['#attached']['library'][] = 'my_module/view-first-page';
  }
}